ruby-jsonchema
ruby-jsonchema copied to clipboard
Patterns with case insensitive
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