ruby-jsonchema icon indicating copy to clipboard operation
ruby-jsonchema copied to clipboard

Patterns with case insensitive

Open gdufloux opened this issue 14 years ago • 0 comments

Hi, dear validation addicts

I recently had an issue when trying to validate a string against a pattern case insensitive. Indeed, the regexp is currently built as following:

# https://github.com/Constellation/ruby-jsonchema/blob/master/lib/jsonschema.rb#L120
Regexp.new(schema['pattern'])

As a result, pattern options are lost when extracting the source only:

r = /cat/ix
schema['pattern'] = r.source
Regexp.new(schema['pattern'])
# => /cat/

Would be great to have the possibility to pass pattern options too:

r = /cat/ix
schema['pattern'] = r.source
schema['pattern'] = r.options
Regexp.new(schema['pattern'],schema['pattern_options']) 
# => /cat/ix

Best regards, Guillaume

gdufloux avatar Apr 27 '11 17:04 gdufloux