class SimpleJSONSchema::Validators::Number
Constants
- FLOAT_FORMAT
Public Instance Methods
casting(value)
click to toggle source
# File lib/simple_json_schema/validators/number.rb, line 17 def casting(value) BigDecimal(value) if value.is_a?(::String) && FLOAT_FORMAT.match?(value) end
validate(scope)
click to toggle source
Calls superclass method
# File lib/simple_json_schema/validators/number.rb, line 8 def validate(scope) value = scope.value return scope.error(:number) unless value.is_a?(::Numeric) return scope.error(:zero_not_allowed) if scope[:not_zero] == true && value.zero? super end