garycourt / JSV

A JavaScript implementation of an extendable, fully compliant JSON Schema validator.
618 stars 84 forks source link

"format": "regex" #20

Closed henchan closed 13 years ago

henchan commented 13 years ago

I have a schema with a section as below

"matching": {
    "title": "include parameter keys matching",
    "description": "only use query parameters whose keys match this regexp",
    "type": "string",
    "format": "regex",
    "default": "/^*$/"
}

My expectation is that an instance whose value for 'matching' is a string but not a valid regular expression will fail validation. However, this is not the case when validating with JSV. Validation does not fail as expected for value "[" which is not a valid ECMA 262/Perl 5 regexp. Am I doing it wrong? Is "format": "regex" not supported in JSV?

garycourt commented 13 years ago

The JSON Schema specification does not require the "format" attribute to be validated as it is more of a meta-data type information like "title" or "description". Therefore, JSV does not perform any type of validation using this attribute.