oferei / json-gate

A friendly, fast JSON schema validator
MIT License
100 stars 16 forks source link

Pattern attribute should accept regexp objects as well as strings #31

Open lini opened 10 years ago

lini commented 10 years ago

Right now the pattern attribute in the schema is always supposed to be a string. However, if we want a regular expression which ignores case, it cannot be done with a string pattern. For example: pattern: "^Phone" will not match the string "phone" Even if i change it to "^[Pp]hone" it will not match an input of "PHONE". I would need to use "^[Pp][Hh][Oo][Nn][Ee]" which is ridiculous.

If pattern can be set to /^phone/i or RegExp("^phone", "i") then it will be a lot easier to use.