Class: Valigator::CSV::FieldValidators::Integer

Inherits:
Base
  • Object
show all
Defined in:
lib/valigator/csv/field_validators/integer.rb

Direct Known Subclasses

Float

Instance Attribute Summary

Attributes inherited from Base

#options

Instance Method Summary collapse

Methods inherited from Base

#==, #initialize

Constructor Details

This class inherits a constructor from Valigator::CSV::FieldValidators::Base

Instance Method Details

#error_messageObject



20
21
22
# File 'lib/valigator/csv/field_validators/integer.rb', line 20

def error_message
  'Invalid integer field'
end

#error_typeObject



14
15
16
# File 'lib/valigator/csv/field_validators/integer.rb', line 14

def error_type
  'invalid_integer'
end

#valid?(value) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
9
10
# File 'lib/valigator/csv/field_validators/integer.rb', line 6

def valid?(value)
  return true if allow_blank and blank? value

  value.is_a?(::Integer) || value.to_i.to_s == value.to_s
end