Sha256: fdf691c110b1386826d16a5a11e5da4d3d6e38f5c590d0f97cb3d0b16892d048
Contents?: true
Size: 800 Bytes
Versions: 7
Compression:
Stored size: 800 Bytes
Contents
require 'json-schema/attribute' module JSON class Schema class DateFormat < FormatAttribute REGEXP = /\A\d{4}-\d{2}-\d{2}\z/ 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" if REGEXP.match(data) begin Date.parse(data) rescue Exception validation_error(processor, error_message, fragments, current_schema, self, options[:record_errors]) end else validation_error(processor, error_message, fragments, current_schema, self, options[:record_errors]) end end end end end end
Version data entries
7 entries across 7 versions & 2 rubygems