Class: ValidatesIdentity::GtDpi::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/validates_identity/gt_dpi/validator.rb

Constant Summary collapse

VALIDATION_REGULAR_EXPRESSION =
/\A([0-9]{8})([0-9])([0-9]{2})([0-9]{2})\z/i.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Validator

Returns a new instance of Validator.



10
11
12
# File 'lib/validates_identity/gt_dpi/validator.rb', line 10

def initialize(value)
  @value = value.to_s
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



8
9
10
# File 'lib/validates_identity/gt_dpi/validator.rb', line 8

def value
  @value
end

Instance Method Details

#formattedObject



23
24
25
# File 'lib/validates_identity/gt_dpi/validator.rb', line 23

def formatted
  value
end

#valid?Boolean

Returns:

  • (Boolean)


14
15
16
17
18
19
20
21
# File 'lib/validates_identity/gt_dpi/validator.rb', line 14

def valid?
  return true if value.blank?
  return false if number.nil?
  return false if birth_state_invalid?
  return false if birth_city_invalid?

  calculated_checksum == checksum
end