Class: PrimitiveTypeValidation
- Inherits:
-
Validation
- Object
- Validation
- PrimitiveTypeValidation
- Defined in:
- lib/json_patterns.rb
Constant Summary
Constants included from Inspectable
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
Methods inherited from Validation
#as_object_members, #expects_an_object?, memoized_new_from_pattern, new_from_pattern, #shallow_describe, #shallow_match?, #validate_from_root
Methods included from HashInitialized
Methods included from DeepEquality
Methods included from Inspectable
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
1092 1093 1094 |
# File 'lib/json_patterns.rb', line 1092 def type @type end |
Instance Method Details
#to_s ⇒ Object
1106 1107 1108 |
# File 'lib/json_patterns.rb', line 1106 def to_s @type.to_s end |
#validate(path, data) ⇒ Object
1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 |
# File 'lib/json_patterns.rb', line 1094 def validate(path, data) if @type === data return [] else return [ValidationUnexpected.new( path: path, expected: @type.to_s, found: JsonType.new_from_value(data).to_s, )] end end |