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

Use maps for validation data #4

Open
jkk opened this issue Jul 29, 2013 · 2 comments
Open

Use maps for validation data #4

jkk opened this issue Jul 29, 2013 · 2 comments

Comments

@jkk
Copy link
Owner

jkk commented Jul 29, 2013

To get the benefits of a format that can be operated on generically, validations should be maps, like Formative field specs:

{:type :required :keys [:foo :bar] :msg "blah"}
{:type :at-least :keys [:foo] :args [1]}

This could actually be added without breaking backwards compatibility. A multimethod could convert vector validations to hash map ones. It would be a bit hacky, but I think not breaking compatibility is important.

This has other benefits, like being able to style certain form fields according to their validations (asterisks next to required inputs, etc).

@abp
Copy link

abp commented Aug 17, 2013

I'm working on a patch for this.
Why would you want to use a multimethod for the conversion from vector to map?
I've just built a function for the conversion.

Should I update the readme to describe the map-based validation format and only mention the vector-based one briefly?

@jkk
Copy link
Owner Author

jkk commented Aug 17, 2013

Was thinking multimethod because the validation elements (keys, args, etc) can be in different positions depending on the type of validation. The multimethod would dispatch on the first value in the vector. It would also work for custom validators not defined in verily. Otherwise all special cases would need to be hard coded into the fn.

Updating the reader sounds good.

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