Class: ValidatesIdentity::PeRuc::PersonValidator
- Inherits:
-
Object
- Object
- ValidatesIdentity::PeRuc::PersonValidator
- Defined in:
- lib/validates_identity/pe_ruc/person_validator.rb
Constant Summary collapse
- VALIDATION_REGULAR_EXPRESSION =
/\A(10)([0-9]{8})([0-9]{1})\z/i.freeze
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #formatted ⇒ Object
-
#initialize(value) ⇒ PersonValidator
constructor
A new instance of PersonValidator.
- #valid? ⇒ Boolean
Constructor Details
#initialize(value) ⇒ PersonValidator
Returns a new instance of PersonValidator.
10 11 12 |
# File 'lib/validates_identity/pe_ruc/person_validator.rb', line 10 def initialize(value) @value = value.to_s end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
8 9 10 |
# File 'lib/validates_identity/pe_ruc/person_validator.rb', line 8 def value @value end |
Instance Method Details
#formatted ⇒ Object
22 23 24 |
# File 'lib/validates_identity/pe_ruc/person_validator.rb', line 22 def formatted value end |
#valid? ⇒ Boolean
14 15 16 17 18 19 20 |
# File 'lib/validates_identity/pe_ruc/person_validator.rb', line 14 def valid? return true if value.blank? return false if value.length != 11 return false if number.nil? verifier_digit == calculated_verifier_digit end |