Module: Modelish::Validations
- Included in:
- Base
- Defined in:
- lib/modelish/validations.rb
Overview
Mixin for validated properties
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #valid? ⇒ Boolean
-
#validate ⇒ Hash<Symbol,Array>
Validates all properties based on configured validators.
-
#validate! ⇒ Object
Validates all properties based on configured validators.
Instance Method Details
#valid? ⇒ Boolean
36 37 38 |
# File 'lib/modelish/validations.rb', line 36 def valid? validate.empty? end |
#validate ⇒ Hash<Symbol,Array>
Validates all properties based on configured validators.
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/modelish/validations.rb', line 17 def validate errors = {} call_validators do |name, | errors[name] ||= [] errors[name] << to_error() end errors end |
#validate! ⇒ Object
Validates all properties based on configured validators.
31 32 33 34 |
# File 'lib/modelish/validations.rb', line 31 def validate! errors = validate raise errors.first[1].first unless errors.empty? end |