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

Add custom validation rule support #4

Closed
plwalters opened this issue May 2, 2016 · 5 comments
Closed

Add custom validation rule support #4

plwalters opened this issue May 2, 2016 · 5 comments
Milestone

Comments

@plwalters
Copy link
Contributor

https://validatejs.org/#custom-validator

Add decorator / fluent API to cover.

@plwalters plwalters added this to the 0.2.0 milestone May 5, 2016
@plwalters plwalters changed the title Add custom validator support Add custom validation rule support May 5, 2016
@apawsey
Copy link
Contributor

apawsey commented May 9, 2016

Has any progress been made on this? Is there a structure that is being proposed?

Quick suggestion would be something in the plugin config that dynamically adds properties to the current validator object, to provide the same api approach with custom validators as built-in ones. Alternatively, a validators.custom property, that we then extend, if it's preferred to have some kind of division?

I assume the custom validators would need to be configured in the DI somehow, as for example the api lookup type validator mentioned in #29 would need httpClient injected in.

@plwalters plwalters modified the milestones: 0.3.1, 0.2.2 May 11, 2016
@plwalters plwalters modified the milestones: 0.3.2, 0.3.1 May 21, 2016
@plwalters
Copy link
Contributor Author

No progress on this one yet PR welcome. Under the covers the ValidationRule class should probably just have a static method for adding the custom rule that works just like the current rule methods work.

@aivins
Copy link

aivins commented May 23, 2016

@PWKad - I ended up hacking this together for myself today but I'm not sure I took the right approach. validate.async returns a promise, whereas aurelia-validatejs seems to strongly assume the opposite. I ended up converting all validate return values into promises, then using Promise.all() to wait on them all at once before returning to the original caller. I also publish each error into the reporter when Promise.all() resolves.

I also had to patch validate.js's async so that it doesn't reject if an async function returns an error. That was stopping me from handling it later on with Promise.all().

@RWOverdijk
Copy link

👍 I'd like to provide a custom validator with my plugin :)

@PWKad I'm fine with working on this. I need some pointers though, how can this be done?

ericIMT added a commit to ericIMT/validatejs that referenced this issue Aug 22, 2016
Add ability to decorators and fluent API in aurelia-validationjs for developer
to extend validate.js with custom validation routines.

issue aurelia#4 aurelia#4
@jdanyow
Copy link
Contributor

jdanyow commented Aug 27, 2016

implemented!

@jdanyow jdanyow closed this as completed Aug 27, 2016
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

5 participants