Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

raise errors in validation procs instead of swallowing them #145

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dgm
Copy link

@dgm dgm commented Aug 8, 2016

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.

…so we can fix early. Setting config option to minimize damage to existing systems
@adzap
Copy link
Owner

adzap commented Aug 8, 2016

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?

@dgm
Copy link
Author

dgm commented Aug 9, 2016

I got no complaints :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants