Skip to content

Patterns with case insensitive #4

Description

@gdufloux

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions