Module: Mixture::Extensions::Validatable::InstanceMethods
- Defined in:
- lib/mixture/extensions/validatable.rb
Overview
The instance methods.
Instance Method Summary collapse
- #errors ⇒ Object
- #invalid? ⇒ Boolean
-
#valid? ⇒ Boolean
Validates the attributes on the record.
Instance Method Details
#errors ⇒ Object
34 35 36 |
# File 'lib/mixture/extensions/validatable.rb', line 34 def errors @errors ||= Hash.new { |h, k| h[k] = [] } end |
#invalid? ⇒ Boolean
30 31 32 |
# File 'lib/mixture/extensions/validatable.rb', line 30 def invalid? !valid? end |
#valid? ⇒ Boolean
Validates the attributes on the record.
21 22 23 24 25 26 27 28 |
# File 'lib/mixture/extensions/validatable.rb', line 21 def valid? @errors = Hash.new { |h, k| h[k] = [] } self.class.attributes.each do |name, attribute| next unless attribute.[:validate] Validate.validate(self, attribute, attribute(name)) end !@errors.values.any?(&:any?) end |