Class: SimpleJSONSchema::Validators::Boolean
- Defined in:
- lib/simple_json_schema/validators/boolean.rb
Constant Summary collapse
- TRUE_VALUES =
['true', '1', 1, 'yes'].freeze
- FALSE_VALUES =
['false', '0', 0, 'no'].freeze
- BOOLEANS =
Set[true, false].freeze
Instance Method Summary collapse
Methods inherited from Base
Instance Method Details
#casting(value) ⇒ Object
17 18 19 20 |
# File 'lib/simple_json_schema/validators/boolean.rb', line 17 def casting(value) return true if TRUE_VALUES.include?(value) return false if FALSE_VALUES.include?(value) end |
#validate(scope) ⇒ Object
11 12 13 14 15 |
# File 'lib/simple_json_schema/validators/boolean.rb', line 11 def validate(scope) value = scope.value return scope.error(:boolean) unless BOOLEANS.include?(value) end |