eclipsesource/play-json-schema-validator

Validator should be tolerant to custom values of 'format' property

Closed this issue · 1 comments

I have discovered that schema validator handles the following known values of format: ["uri", "hostname", "email", "ipv4", "ipv6", "date-time", "uuid" ]. If a schema specifies something else, validator raises an error about unknown format.

According to the meta schema definition for JSON-schema, "format" property is a flexible string, which does not have any constraints. Users may define any possible value in the format field.

Moreover, the meta-schema for JSON-schema uses "regex" value, which is used in the definition of pattern field:
"pattern": {
"type": "string",
"format": "regex"
}

Desirable behavior: unknown formats are ignored or (better) a custom client's callback is invoked to let the client handle custom formats.

Thanks for the report! The validator supports custom formats via the addFormat method, but it's true that unknown formats raise errors. I'll change the default behaviour.