Sha256: 91bafba82f0cc938456706c8e174db340ead0b2734c6fc10b0425c78379bdf1c

Contents?: true

Size: 544 Bytes

Versions: 5

Compression:

Stored size: 544 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, options[:record_errors])
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
json-schema-1.0.3 lib/json-schema/attributes/pattern.rb
json-schema-1.0.2 lib/json-schema/attributes/pattern.rb
seomoz-json-schema-1.0.1 lib/json-schema/attributes/pattern.rb
json-schema-1.0.1 lib/json-schema/attributes/pattern.rb
json-schema-1.0.0 lib/json-schema/attributes/pattern.rb