Module: Performify::Validation::InstanceMethods
- Defined in:
- lib/performify/validation.rb
Instance Method Summary collapse
- #errors ⇒ Object
- #errors!(new_errors) ⇒ Object
- #errors? ⇒ Boolean
- #schema ⇒ Object
- #validate(args) ⇒ Object
Instance Method Details
#errors ⇒ Object
33 34 35 |
# File 'lib/performify/validation.rb', line 33 def errors @errors ||= {} end |
#errors!(new_errors) ⇒ Object
29 30 31 |
# File 'lib/performify/validation.rb', line 29 def errors!(new_errors) errors.merge!(new_errors) end |
#errors? ⇒ Boolean
37 38 39 |
# File 'lib/performify/validation.rb', line 37 def errors? errors.any? end |
#schema ⇒ Object
18 19 20 |
# File 'lib/performify/validation.rb', line 18 def schema self.class.schema end |
#validate(args) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/performify/validation.rb', line 22 def validate(args) return args if schema.nil? result = schema.call(args) errors!(result.errors) unless result.success? result.output end |