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