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

Dynamic validation boundaries #281

Closed
ares opened this issue Feb 20, 2012 · 2 comments
Closed

Dynamic validation boundaries #281

ares opened this issue Feb 20, 2012 · 2 comments

Comments

@ares
Copy link
Contributor

ares commented Feb 20, 2012

Hi,

I found one thing I'm missing. Imagine you have this validation in Value model that is limited by it's Boundary setting (another model)

validates :value, :numericality => { :less_than => Proc.new {|o| o.boundary.maximum } }

This Proc works great in rails but CSV probably expect just number in here. CSV should eval this Proc before using it. I think adding this won't be hard but I couldn't trace a right place to edit.

ares added a commit to ares/client_side_validations that referenced this issue Feb 22, 2012
ares added a commit to ares/client_side_validations that referenced this issue Feb 22, 2012
@ares
Copy link
Contributor Author

ares commented Feb 22, 2012

I made two identical patches/commits, one is based on master (pull request made for this) and second one is based on latest tagged version. I'd be happy to provide also test for this but I was not able to run them on my linux box. Maybe you could provide some info on wiki how one should run tests. I'm getting a lot of errors (not failed test) running rake test (and rake test:ruby).

This patch basically calls a Proc instance if specified in validation hash. I think it greatly extends functionality as I wrote in example in first comment.

ares added a commit to ares/client_side_validations that referenced this issue Mar 26, 2012
This allows ClientSideValidations to respect Proc parameters
as ActiveModel does.

I added also tests for new functionality. Missed only lenght test
because rails does not allow Procs for LengthValidator
@bcardarella
Copy link
Contributor

Hey @ares I'm going to close this issue in favor of #284

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

No branches or pull requests

2 participants