Skip to content

Commit 6da1af2

Browse files
committed
Require only method #match? for regexp
1 parent 5f70ea6 commit 6da1af2

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

lib/json_schemer/schema/base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ def validate_string(instance, &block)
416416

417417
yield error(instance, 'maxLength') if max_length && data.size > max_length
418418
yield error(instance, 'minLength') if min_length && data.size < min_length
419-
yield error(instance, 'pattern') if pattern && resolve_regexp(pattern) !~ data
419+
yield error(instance, 'pattern') if pattern && !resolve_regexp(pattern).match?(data)
420420
yield error(instance, 'format') if format? && spec_format?(format) && !valid_spec_format?(data, format)
421421

422422
if content_encoding || content_media_type

test/json_schemer_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -927,8 +927,8 @@ def initialize(pattern)
927927
self.class.counts += 1
928928
end
929929

930-
def !~(string)
931-
@regexp !~ string
930+
def match?(string)
931+
@regexp.match?(string)
932932
end
933933
end
934934

0 commit comments

Comments
 (0)