Class: Datum::FormValidator::Attribute
- Inherits:
-
Object
- Object
- Datum::FormValidator::Attribute
- Defined in:
- lib/datum/form_validator/entities/attribute.rb
Defined Under Namespace
Classes: ValidationError
Instance Attribute Summary collapse
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#form ⇒ Object
Returns the value of attribute form.
-
#name ⇒ Object
Returns the value of attribute name.
-
#validations ⇒ Object
Returns the value of attribute validations.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(attrs = {}) ⇒ Attribute
constructor
A new instance of Attribute.
- #valid? ⇒ Boolean
Constructor Details
#initialize(attrs = {}) ⇒ Attribute
Returns a new instance of Attribute.
12 13 14 15 16 |
# File 'lib/datum/form_validator/entities/attribute.rb', line 12 def initialize(attrs = {}) @name = attrs[:name] @value = attrs[:value] @validations = attrs.fetch(:validations, []) end |
Instance Attribute Details
#errors ⇒ Object
Returns the value of attribute errors.
10 11 12 |
# File 'lib/datum/form_validator/entities/attribute.rb', line 10 def errors @errors end |
#form ⇒ Object
Returns the value of attribute form.
10 11 12 |
# File 'lib/datum/form_validator/entities/attribute.rb', line 10 def form @form end |
#name ⇒ Object
Returns the value of attribute name.
10 11 12 |
# File 'lib/datum/form_validator/entities/attribute.rb', line 10 def name @name end |
#validations ⇒ Object
Returns the value of attribute validations.
10 11 12 |
# File 'lib/datum/form_validator/entities/attribute.rb', line 10 def validations @validations end |
#value ⇒ Object
Returns the value of attribute value.
10 11 12 |
# File 'lib/datum/form_validator/entities/attribute.rb', line 10 def value @value end |
Instance Method Details
#valid? ⇒ Boolean
18 19 20 21 22 23 |
# File 'lib/datum/form_validator/entities/attribute.rb', line 18 def valid? validate! true rescue ValidationError false end |