Class: Rentlinx::BaseValidator
- Inherits:
-
Object
- Object
- Rentlinx::BaseValidator
- Defined in:
- lib/rentlinx/validators/base_validator.rb
Overview
This is the base validator. It encapsulates all the logic shared between the various validators.
Direct Known Subclasses
AddressValidator, AmountValidator, CityValidator, PhoneValidator, StateValidator, UrlValidator, ZipValidator
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
Instance Method Summary collapse
-
#initialize(val) ⇒ BaseValidator
constructor
Creates a new instance of the class, and validates but BaseValidator should never be directly instantiated.
-
#processed_value ⇒ Object
The processed value after validation of the attribute.
-
#valid? ⇒ Boolean
Determines the validity of the attribute.
Constructor Details
#initialize(val) ⇒ BaseValidator
Creates a new instance of the class, and validates but BaseValidator should never be directly instantiated.
9 10 11 12 13 |
# File 'lib/rentlinx/validators/base_validator.rb', line 9 def initialize(val) @value = val @error = '' validate end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
5 6 7 |
# File 'lib/rentlinx/validators/base_validator.rb', line 5 def error @error end |
Instance Method Details
#processed_value ⇒ Object
The processed value after validation of the attribute.
25 26 27 |
# File 'lib/rentlinx/validators/base_validator.rb', line 25 def processed_value @value end |
#valid? ⇒ Boolean
Determines the validity of the attribute.
18 19 20 |
# File 'lib/rentlinx/validators/base_validator.rb', line 18 def valid? @error == '' end |