validates_timeliness icon indicating copy to clipboard operation
validates_timeliness copied to clipboard

raise errors in validation procs instead of swallowing them

Open dgm opened this issue 7 years ago • 2 comments

As we have been discussing in a patch comment thread, the least surprise would be for the validations to raise errors as the occur, not swallow them. I think this will give us that without breaking existing systems.

dgm avatar Aug 08 '16 18:08 dgm

Thanks! Looks good, though I had in mind to merge the ignore/raise/error into a single config setting. Then override the old setting accordingly.

Something like this

 e if ValidatesTimeliness.validation_errors == :raise
 if ValidatesTimeliness.validation_errors == :message

or heaven forbid a case statement

case ValidatesTimeliness.validation_errors
when :raise 
  raise e
when :message
  add_error(record, message)
when :log
   Rails.logger.warn('validation error')
else # :ignore
end

thoughts?

adzap avatar Aug 08 '16 22:08 adzap

I got no complaints :)

dgm avatar Aug 09 '16 14:08 dgm