Module: Modelish::Validations
- Included in:
- Base
- Defined in:
- lib/modelish/validations.rb
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
33 34 35 |
# File 'lib/modelish/validations.rb', line 33 def valid? validate.empty? end |
#validate ⇒ Hash<Symbol,Array>
Validates all properties based on configured validators.
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/modelish/validations.rb', line 14 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.
28 29 30 31 |
# File 'lib/modelish/validations.rb', line 28 def validate! errors = validate raise validate.first[1].first unless validate.empty? end |