Skip to content

Support valueConstraint for UriTemplate and UUID #377

@nickevansuk

Description

@nickevansuk

See documentation here, rules as follows (though perhaps could be achieved within one rule “value-constraint” rule file.

Note the reason these specific valueConstraints and are not just standalone targeted rules is that they also allow the language-specific SDKs to make use of them for strong typing and data validation.

Note valueConstraint will need to be added as a property to the Field class so that it is accessible:

const Field = class {

"valueConstraint": "UriTemplate"

  • Checks that the value is a valid Uri Template, and outputs a FAILURE if not

An aside:

valueConstraint could also be used to optimise the following, which may speed up validation. So replace the below with if (this.valueConstraint === 'UriTemplate' && PropertyHelper.isUrlTemplate(data)) {:

// Is this a URL template?
// This processes most strings... so could be a bit intensive
if (PropertyHelper.isUrlTemplate(data)) {
returnType = 'https://schema.org/Text';

"valueConstraint": "UUID"

  • Checks that the value is a valid lowercase UUID, and outputs a FAILURE if not. The error message should cite RFC 4122 Section 3, which requires that UUID characters be generated in lower case.

Metadata

Metadata

Assignees

Labels

ruleA rule suggestion for implementation

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions