Class: Skooma::Validators::Int32

Inherits:
JSONSkooma::Validators::Base
  • Object
show all
Defined in:
lib/skooma/validators/int_32.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.assert?(instance) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/skooma/validators/int_32.rb', line 6

def self.assert?(instance)
  instance.type == "number" && instance == instance.to_i
end

Instance Method Details

#call(instance) ⇒ Object

Raises:

  • (JSONSkooma::Validators::FormatError)


10
11
12
13
14
# File 'lib/skooma/validators/int_32.rb', line 10

def call(instance)
  return if instance.value.bit_length <= 32

  raise JSONSkooma::Validators::FormatError, "must be a valid int32"
end