diff --git a/lib/json_schemer/schema/base.rb b/lib/json_schemer/schema/base.rb index a947289c..ce5e5bca 100644 --- a/lib/json_schemer/schema/base.rb +++ b/lib/json_schemer/schema/base.rb @@ -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 diff --git a/test/json_schemer_test.rb b/test/json_schemer_test.rb index ca370c8e..c497bed9 100644 --- a/test/json_schemer_test.rb +++ b/test/json_schemer_test.rb @@ -927,8 +927,8 @@ def initialize(pattern) self.class.counts += 1 end - def !~(string) - @regexp !~ string + def match?(string) + @regexp.match?(string) end end