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:
"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.
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
valueConstraintwill need to be added as a property to theFieldclass so that it is accessible:data-model-validator/src/classes/field.js
Line 4 in 652c8d9
"valueConstraint": "UriTemplate"
An aside:
"valueConstraint": "UUID"