1
votes

I am trying to implement a validator for JSON schema using the v4 Draft. For the "type" keyword, it can be either a string or an array of strings as written here In the case if it is an array, how the validation will work?

For example: the keyword "maximum" is valid for numeric types while the keyword "maxLength" is valid for the string type. If I specify a type array of both "integer" and "string" will both keywords be valid or none or what?

1

1 Answers

0
votes

If the value being validated is numeric, then maximum will be used for validation. If the value being validated is a string, then maxLength will be used for validation.

If type is not present, or it contains a matching type, then other keywords are used based on the type of the data, not what's in type.