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

Allow proc and symbol as values for only_integer of NumericalityValidator #15834

Merged

Conversation

rmehner
Copy link
Contributor

@rmehner rmehner commented Jun 20, 2014

We have to dynamically decide of the value should be validated as float or as integer. This PR adds the possibility of defining a symbol or a Proc as value for the only_integer option, while preserving the old behaviour of just setting a boolean.

I see one difference in behaviour to the existing version: If you provided a symbol instead of a boolean before, it was always handled as truthness (the same as only_integer: true). With this PR applied it would raise an NoMethodError, because it tries to call the method on the object. Should I handle that to keep full backwards compatibility?

Thank you Rails team for your hard work! Happy to get any feedback :)

@arthurnn
Copy link
Member

🆒 👍

@rafaelfranca
Copy link
Member

It is fine as it is now. I don't think people will have trouble to update their application to change symbol to true if they were expecting the symbol to be a truthy value.

rafaelfranca added a commit that referenced this pull request Jun 26, 2014
…_integer

Allow proc and symbol as values for `only_integer` of `NumericalityValidator`
@rafaelfranca rafaelfranca merged commit 6099b64 into rails:master Jun 26, 2014
@rmehner rmehner deleted the allow_proc_and_symbol_for_only_integer branch June 26, 2014 10:05
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.

None yet

3 participants