Module: Xeroizer::Record::ValidationHelper::InstanceMethods

Defined in:
lib/xeroizer/record/validation_helper.rb

Instance Method Summary collapse

Instance Method Details

#errors_for(attribute) ⇒ Object



61
62
63
64
65
# File 'lib/xeroizer/record/validation_helper.rb', line 61

def errors_for(attribute)
  if errors.is_a?(Array)
    errors.find_all { | (attr, msg) | attr == attribute }.map { | (attr, msg) | msg }
  end
end

#valid?Boolean

Returns:

  • (Boolean)


51
52
53
54
55
56
57
58
59
# File 'lib/xeroizer/record/validation_helper.rb', line 51

def valid?
  @errors = []
  if self.class.validators
    self.class.validators.each do | validator |
      validator.validate(self)
    end
  end
  @errors.size == 0
end