Class: Validation
- Inherits:
-
Object
- Object
- Validation
- Defined in:
- lib/yodel/models/core/validations/validation.rb
Direct Known Subclasses
EmailAddressValidation, EmbeddedRecordsValidation, ExcludedFromValidation, ExcludesCombinationsValidation, FormatValidation, IncludedInValidation, IncludesCombinationsValidation, LengthValidation, PasswordConfirmationValidation, RequiredValidation, UniqueValidation
Instance Attribute Summary collapse
-
#field ⇒ Object
Returns the value of attribute field.
-
#params ⇒ Object
Returns the value of attribute params.
Class Method Summary collapse
Instance Method Summary collapse
- #describe ⇒ Object
-
#initialize(params) ⇒ Validation
constructor
A new instance of Validation.
- #to_json(*a) ⇒ Object
Constructor Details
#initialize(params) ⇒ Validation
Returns a new instance of Validation.
28 29 30 |
# File 'lib/yodel/models/core/validations/validation.rb', line 28 def initialize(params) @params = params end |
Instance Attribute Details
#field ⇒ Object
Returns the value of attribute field.
2 3 4 |
# File 'lib/yodel/models/core/validations/validation.rb', line 2 def field @field end |
#params ⇒ Object
Returns the value of attribute params.
2 3 4 |
# File 'lib/yodel/models/core/validations/validation.rb', line 2 def params @params end |
Class Method Details
.validate(type, params, field, name, value, record, errors) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/yodel/models/core/validations/validation.rb', line 4 def self.validate(type, params, field, name, value, record, errors) validation = case type when 'excluded_from' ExcludedFromValidation when 'excludes_combinations' ExcludesCombinationsValidation when 'format' FormatValidation when 'included_in' IncludedInValidation when 'includes_combinations' IncludesCombinationsValidation when 'length' LengthValidation when 'required' RequiredValidation when 'unique' UniqueValidation when 'password_confirmation' PasswordConfirmationValidation end validation.validate(params, field, name, value, record, errors) end |
Instance Method Details
#describe ⇒ Object
32 33 34 |
# File 'lib/yodel/models/core/validations/validation.rb', line 32 def describe "is invalid" end |
#to_json(*a) ⇒ Object
36 37 38 |
# File 'lib/yodel/models/core/validations/validation.rb', line 36 def to_json(*a) describe.to_json(*a) end |