search for: randomlyvalid

Displaying 1 result from an estimated 1 matches for "randomlyvalid".

2012 Aug 05
0
ActiveRecord::Validator vs ActiveModel::Validator
...<< “is not valid” unless record.send(email_field) =~ /^[a-z]$/ end end class Account < ActiveRecord::Base validates_with EmailValidator, :attr => :email end Where is this ActiveRecord::Validator coming from? Also why does it exist when you can simply do this in ActiveModel: class RandomlyValidator < ActiveModel::Validator def validate(record) record.errors[:base] << “FAIL #1” unless first_hurdle(record) #add error messages to the whole object instead of a particular attribute using the :base key. record.errors[:base] << “Fail #2” unless second_hurdle(record)...