-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Validation updates: call before
before validation / added param value when raising ValidationError
#239
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
Conversation
@schmurfy maybe you can add a section about coercion with virtus? I wasn't able to find a list of the supported types. |
Why running before block before the validation is applied ? I would prefer a lot adding another method like "before_validation" or something like that and keep the current one untouched. As for the supported Virtus types I don't have a closed list either but pretty much all the basic ruby types should be supported. |
I'm okay adding a before_validation method if people think it would be useful? You asked why I want to run the block before validation. Things like adding headers, authenticating or transforming/creating some piece of information are really bizarre to run after validation. But would definitely be solved in a before_validation. Also want to make sure this is fully backwards compatible. |
If you don't define any validation nothing will be done in the validation step so we remain fully compatible :) |
I am with @schmurfy, I'm merging this. Feel free to make a PR that introduces a before_validation callback. |
Validation updates: call `before` before validation / added param value when raising ValidationError
by merging this the before block is now run before the validation, since we agree with me I am not sure this is what you wanted to do. |
@schmurfy I think it's correct, because |
I am really not sure having before run before anything else is the expected behavior but going with a before_validation and after_validation would definitely remove any doubts on what to expects. |
I'm happy to add the additional method. Right now its just a matter of verbiage. Our options are |
This is an update to #221
before
before validating params