Sha256: d8de9f97186401f472f4fe4bd8d7225cd5cb25888f0db8f94dd69cabd6a30616
Contents?: true
Size: 859 Bytes
Versions: 1
Compression:
Stored size: 859 Bytes
Contents
require 'json-schema/attribute' require 'uri' module JSON class Schema class DateFormat < FormatAttribute def self.validate(current_schema, data, fragments, processor, validator, options = {}) if data.is_a?(String) error_message = "The property '#{build_fragment(fragments)}' must be a date in the format of YYYY-MM-DD" r = Regexp.new('^\d\d\d\d-\d\d-\d\d$') if (r.match(data)) begin Date.parse(data) rescue Exception validation_error(processor, error_message, fragments, current_schema, self, options[:record_errors]) return end else validation_error(processor, error_message, fragments, current_schema, self, options[:record_errors]) return end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
json-schema-2.3.0 | lib/json-schema/attributes/formats/date.rb |