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

Serialization of validator functions that accept arguments #200

Closed
udos86 opened this issue Dec 3, 2016 · 7 comments
Closed

Serialization of validator functions that accept arguments #200

udos86 opened this issue Dec 3, 2016 · 7 comments

Comments

@udos86
Copy link
Owner

udos86 commented Dec 3, 2016

Validators that accept an argument like Validators.maxLength cannot be serialized at the moment.

@udos86 udos86 changed the title Bug in Validators serialization Serialization of validator functions that accept arguments Dec 3, 2016
@udos86 udos86 removed the bug label Dec 3, 2016
@udos86
Copy link
Owner Author

udos86 commented Dec 3, 2016

Will probably introduce a breaking change to solve this.

@DavyJohnes
Copy link
Contributor

Hi @udos86,
This is great improvement, however, it seems like there is not way to provide custom validators. By "custom validator" I mean a simple functions, which I previously just included in validators array. As far as I understand currently ng2-forms just picks validators function from @angular/forms/Validators, it means that there is no way to use custom validators.

@udos86
Copy link
Owner Author

udos86 commented Dec 12, 2016

@DavyJohnes

In order to use custom validators please provide them via NG_VALIDATORS / NG_ASYNC_VALIDATORS at first (see http://blog.thoughtram.io/angular/2016/03/14/custom-validators-in-angular-2.html).

But there is a bug, you're right!

@udos86 udos86 reopened this Dec 12, 2016
@udos86
Copy link
Owner Author

udos86 commented Dec 12, 2016

@DavyJohnes Please have a look at 8ddf56c. This fix allows you to reference any custom validator given that it's provided via NG_VALIDATORS or NG_ASYNC_VALIDATORS.

@udos86 udos86 closed this as completed in 8ddf56c Dec 12, 2016
@udos86 udos86 added the bug label Dec 12, 2016
@DavyJohnes
Copy link
Contributor

@udos86 thanks a lot, will try to use this new approach.

@udos86
Copy link
Owner Author

udos86 commented Dec 12, 2016

@DavyJohnes You're welcome! Thank you for letting me know about the bug.

@udos86
Copy link
Owner Author

udos86 commented Dec 12, 2016

@DavyJohnes I've added a little guide in the README.md: https://github.com/udos86/ng2-dynamic-forms#custom-validators

@udos86 udos86 added the core label Jan 29, 2017
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

2 participants