-
Notifications
You must be signed in to change notification settings - Fork 7
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
Built-in validator suggestion #3
Comments
@alolis I have also written that custom validator before. I haven't put it in metis yet because of some questions around how the syntax would work. I was thinking along these lines. ; with one item validator
(defvalidator user-validator
[:zipcodes :collection {:item-validator [:numericality {:equal-to 5 :only-integer true}]}])
; with many item validators
(defvalidator user-validator
[:numbers :collection {:item-validator [:numericality {:less-than 5} :length {:equal-to 3} :some-custom-validator]}]) What do you think? |
That's exactly how I implemented mine as well :) I think it's pretty straight forward and clean |
Hey Myles, I was wondering if you have a fork with the collection feature somewhere; I wanted to have a look at it because it seems I use it more often lately :) ...or did it make it to core and I haven't noticed? |
Unfortunatley it was never added to metis. I built it into the project is was working on at the time. |
Definitely a useful thing to have in metis :) If we get to vote about it it's +1 from me :p Do you think you can share the function at least? I feel it's much more complete than what I got. If not, no problem at all. |
Hello!
I found myself using very often a custom validator I made in order to check all the elements in a vector if they are numeric in some cases or if they match a regex pattern in some other cases.
For example, the case where I mostly use it is when I wanna validate the a vector query parameter.
e.g www.example.com?items[]=1&items[]=2
And then inside my code i take the items and use my validator, which works just fine but i thought I could propose the implementation of a build-in vector-of validator which as options will take the currently available validators and check against them if all vector elements pass the validation.
The text was updated successfully, but these errors were encountered: