Class: JSON::Schema::CustomFormat
- Inherits:
-
FormatAttribute
- Object
- Attribute
- FormatAttribute
- JSON::Schema::CustomFormat
- Defined in:
- lib/json-schema/attributes/formats/custom.rb
Constant Summary
Constants inherited from Attribute
Attribute::TYPE_CLASS_MAPPINGS
Instance Method Summary collapse
-
#initialize(validation_proc) ⇒ CustomFormat
constructor
A new instance of CustomFormat.
- #validate(current_schema, data, fragments, processor, validator, options = {}) ⇒ Object
Methods inherited from FormatAttribute
Methods inherited from Attribute
build_fragment, data_valid_for_type?, type_of_data, validate, validation_error, validation_errors
Constructor Details
#initialize(validation_proc) ⇒ CustomFormat
Returns a new instance of CustomFormat.
7 8 9 |
# File 'lib/json-schema/attributes/formats/custom.rb', line 7 def initialize(validation_proc) @validation_proc = validation_proc end |
Instance Method Details
#validate(current_schema, data, fragments, processor, validator, options = {}) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/json-schema/attributes/formats/custom.rb', line 11 def validate(current_schema, data, fragments, processor, validator, = {}) begin @validation_proc.call data rescue JSON::Schema::CustomFormatError => e = "The property '#{self.class.build_fragment(fragments)}' #{e.}" self.class.validation_error(processor, , fragments, current_schema, self, [:record_errors]) end end |