Skip to content

How should asset processing properties be validated? #17

@l0b0

Description

@l0b0

The schema contains the following section:

{
  "type": "object",
  "$comment": "This validates the fields in Collection Assets, but does not require them.",
  "required": [
    "assets"
  ],
  "properties": {
    "assets": {
      "type": "object",
      "not": {
        "additionalProperties": {
          "not": {
            "allOf": [
              {
                "$ref": "#/definitions/require_any_field"
              },
              {
                "$ref": "#/definitions/fields"
              }
            ]
          }
        }
      }
    }
  }
}

What is the semantics meant to be? Are the nots actually meant to be there? I would expect the idea is that if there are any assets then any processing properties within them should be valid, not invalid. In code, I'd expect the following test to pass:

it('should fail validation when asset processing expression is invalid', async () => {
	// given
	example.assets = {
		'example': {
			'href': 'https://example.org/file.xyz',
			'processing:expression': null,
		}
	};

	// when
	let valid = validate(example);

	// then
	expect(valid).toBeFalsy();
	expect(
		validate.errors.some(
			(error) =>
				error.instancePath === '/assets/example/processing:expression'
				&& error.message === 'must be object',
		)
	).toBeTruthy();
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions