Class: ActiveFields::Validators::BaseValidator
- Inherits:
-
Object
- Object
- ActiveFields::Validators::BaseValidator
- Defined in:
- lib/active_fields/validators/base_validator.rb
Overview
Validates the active_value value
Direct Known Subclasses
BooleanValidator, DateArrayValidator, DateTimeArrayValidator, DateTimeValidator, DateValidator, DecimalArrayValidator, DecimalValidator, EnumArrayValidator, EnumValidator, IntegerArrayValidator, IntegerValidator, TextArrayValidator, TextValidator
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(**options) ⇒ BaseValidator
constructor
A new instance of BaseValidator.
-
#valid? ⇒ Boolean
Returns ‘true` if no errors are found, `false` otherwise.
-
#validate(value) ⇒ Object
Performs the validation and adds errors to the ‘errors` list.
Constructor Details
#initialize(**options) ⇒ BaseValidator
9 10 11 12 |
# File 'lib/active_fields/validators/base_validator.rb', line 9 def initialize(**) @options = @errors = Set.new end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
7 8 9 |
# File 'lib/active_fields/validators/base_validator.rb', line 7 def errors @errors end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/active_fields/validators/base_validator.rb', line 7 def @options end |
Instance Method Details
#valid? ⇒ Boolean
Returns ‘true` if no errors are found, `false` otherwise.
22 23 24 |
# File 'lib/active_fields/validators/base_validator.rb', line 22 def valid? errors.empty? end |
#validate(value) ⇒ Object
Performs the validation and adds errors to the ‘errors` list. Returns `true` if no errors are found, `false` otherwise.
16 17 18 19 |
# File 'lib/active_fields/validators/base_validator.rb', line 16 def validate(value) perform_validation(value) valid? end |