Hi there,
I've got a custom setter in a model that add errors in the case that the given value is invalid. In the case that it is invalid, I've had a lot of difficulty getting the model to validate false. It looks like in active model we call errors.clear before run_validations!. This makes sense to me, as you might save a record, validate false, update the values, and then not want to keep the old errors.
Is there any way around this? Best I could come up with is to set an attr_accessor flag to :invalid if the setter was invalid and then validate absence of that attr_accessor.
Would there be interest in a PR that extended errors to have some persistent values through the validation stack? As in, you set a sticky error that doesn't get removed when you call valid? Or something? Sorry, that part of this is not super thought-out.
--
Kevin D. Deisz
TrialNetworks - part of DrugDev
Software Developer
383 Elliot Street, Suite G
Newton, MA 02464