-
Notifications
You must be signed in to change notification settings - Fork 367
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
Custom Validators with Production build are not working : TypeError: v is not a function #424
Comments
As described in chapter on |
Thanks @udos86 We are using Angular CLI in our project. To exclude a file from mangling in Angular CLI setup, we will need to eject and then customize the webpack.config. As per discussion within, we kept it as last choice. Do you think if there could be any other way? I'll also try by extending FormService and probably let you know. Also, in following up to this #417 issue, could you please why custom validator does not work when we provide 'null' against it in model. Thanks a lot ! |
I am able to make it work by extending the DynamicFormService and overriding the 'getCustomValidatorFn' method, and then passing on my custom validator function. Look at this. What is your opinion? I believe you should device some solution to this problem so that people can use custom validators even with production build. Production build is very much obvious and not everyone be comfotable with ejecting Angular CLI config to configure webpack. One simple solution could be to let people override the method 'getCustomValidatorFn' (or you may have any other method name) and provide their own function. Thanks. Rahul |
@rahul-winner Thanks for your proposal! I'm aware of CLI's lack of custom mangling options (see angular/angular-cli#5192). All in all it's not that easy. In order to provide JSON export/import and easy declaration a validator has to be referenced by it's function name. It's the only property that a validator can be safely identified by. When mangled this information is irretrievably lost. I'll make this a high priority issue but I can't promise a flawless solution on this. |
Ok, so my favorite approach to this so far would be to provide an alternate syntax for defining validators on a dynamic form model like this:
|
Ok, implementation's ready now and will be released this weekend! Please have a look at updated docs. |
Thanks ton @udos86 .. Waiting for it. |
Thanks a ton @udos86 |
@udos86
I've already raised the issue #417. After your suggestion I'm able to work my custom validator. However, now I'm facing problem with production build which is reported with #271
I've also tried your workaround/solution [ref : commit] by having a property with same function name, however it also didn't work. With this, I got error : TypeError: v is not a function
Could you please help me out and suggest me what should be the definition of validator so that it can work in both environments dev as well prod.
Thanks a lot !
Rahul
The text was updated successfully, but these errors were encountered: