Sha256: 85cc2ef5ad76619e36ede90baadcb55af7c8bc73801edec0e121d3d92fb54e6c

Contents?: true

Size: 550 Bytes

Versions: 7

Compression:

Stored size: 550 Bytes

Contents

module JSON
  class Schema
    class PatternAttribute < Attribute
      def self.validate(current_schema, data, fragments, validator, options = {})
        if data.is_a?(String)
          r = Regexp.new(current_schema.schema['pattern'])
          if (r.match(data)).nil?
            message = "The property '#{build_fragment(fragments)}' did not match the regex '#{current_schema.schema['pattern']}'"
            validation_error(message, fragments, current_schema, self, options[:record_errors])
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
json-schema-1.0.10 lib/json-schema/attributes/pattern.rb
json-schema-1.0.9 lib/json-schema/attributes/pattern.rb
json-schema-1.0.8 lib/json-schema/attributes/pattern.rb
json-schema-1.0.7 lib/json-schema/attributes/pattern.rb
json-schema-1.0.6 lib/json-schema/attributes/pattern.rb
json-schema-1.0.5 lib/json-schema/attributes/pattern.rb
json-schema-1.0.4 lib/json-schema/attributes/pattern.rb