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

Declarative setting of validation rules #48

Open
Nettsentrisk opened this issue Mar 2, 2017 · 2 comments
Open

Declarative setting of validation rules #48

Nettsentrisk opened this issue Mar 2, 2017 · 2 comments

Comments

@Nettsentrisk
Copy link

Like the declarative nature of providing error messages, it should be possible to set validation rules on inputs declaratively.

jQuery Validation has a data-rule-* format for these, where you can pass settings in to the validation rule in the attribute value, if necessary.

As far as I can see from the code as it is now, you'd have to iterate over all the inputs that need a custom validator and pass them through the addValidator method one by one.

@Boldewyn
Copy link
Contributor

I'm not against such a feature (and implemented things like that myself several times), but what would be a rule that one could add, and that cannot be built with a combination of existing attributes like pattern? Or would that be a general-purpose rule like creditcard or phoneUS like in jQuery Validation?

The point why I'm a bit hesitating is, that I plan with #14 to open up the inner workings of Hyperform, so one could write plugins, that could do things like, in the extreme case, add support for new type values. I haven't quite made up my mind how that will work out in the end, but I'd like to sort that out first, before implementing a rules feature.

@Nettsentrisk
Copy link
Author

The "equalTo" validation from jQuery Validation is maybe a good example of this. Other use cases are when you need to validate something via an AJAX request (I have another issue filed for clarification/example of how this can be done with hyperform).

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