is there a way that can validate a single field from the boolean returned by a callback method? something like:
validate_with_callback :title, :callback_method, 'an error message'
doesn't have to be exactly the same, but is there something similar built-in in rails?
I suppose you could do something like:
def self.validate_with_callback(attr, method, error)
validate do |record|
record.errors.add attr, error unless record.send(method)
end
end
But this is just a dumb wrapper around validate
, so I'd just call it directly.