class JSON::Schema::DateFormat
Constants
- REGEXP
Public Class Methods
validate(current_schema, data, fragments, processor, validator, options = {})
click to toggle source
# File lib/json-schema/attributes/formats/date.rb, line 8 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 ArgumentError => e raise e unless e.message == 'invalid date' 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