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

Transforming validator #17

Open
logaan opened this issue Jul 7, 2015 · 0 comments
Open

Transforming validator #17

logaan opened this issue Jul 7, 2015 · 0 comments

Comments

@logaan
Copy link
Owner

logaan commented Jul 7, 2015

So when you've got a webform submitted it'll come through like {:name "Foo" :age "18"} and you need to transform :age to be a number before performing lt or gt checks against it. So a transforming validator could take those lt/gt validations and pass a parsed value to them. Eg:

(def as-int
  (transformer
   :validator (matches #"\d+"))
   :parser    Integer/parseInt}))

(attr :age (as-int (greater-than 17)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant