Skip to content

Commit

Permalink
Require only method #match? for regexp
Browse files Browse the repository at this point in the history
  • Loading branch information
andrykonchin committed Nov 3, 2022
1 parent 5f70ea6 commit 6da1af2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/json_schemer/schema/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ def validate_string(instance, &block)

yield error(instance, 'maxLength') if max_length && data.size > max_length
yield error(instance, 'minLength') if min_length && data.size < min_length
yield error(instance, 'pattern') if pattern && resolve_regexp(pattern) !~ data
yield error(instance, 'pattern') if pattern && !resolve_regexp(pattern).match?(data)
yield error(instance, 'format') if format? && spec_format?(format) && !valid_spec_format?(data, format)

if content_encoding || content_media_type
Expand Down
4 changes: 2 additions & 2 deletions test/json_schemer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -927,8 +927,8 @@ def initialize(pattern)
self.class.counts += 1
end

def !~(string)
@regexp !~ string
def match?(string)
@regexp.match?(string)
end
end

Expand Down

0 comments on commit 6da1af2

Please sign in to comment.