Class: ValidatesIdentity::PaRuc::PersonValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/validates_identity/pa_ruc/person_validator.rb

Constant Summary collapse

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ PersonValidator

Returns a new instance of PersonValidator.



10
11
12
# File 'lib/validates_identity/pa_ruc/person_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/pa_ruc/person_validator.rb', line 8

def value
  @value
end

Instance Method Details

#formattedObject



20
21
22
23
24
# File 'lib/validates_identity/pa_ruc/person_validator.rb', line 20

def formatted
  return if result.nil?

  "#{result[1]}-#{result[2]}-#{result[3]}"
end

#valid?Boolean

Returns:

  • (Boolean)


14
15
16
17
18
# File 'lib/validates_identity/pa_ruc/person_validator.rb', line 14

def valid?
  return true if value.blank?

  birth_state.present? && birth_state_valid?
end