-
Notifications
You must be signed in to change notification settings - Fork 369
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
customValidator is not provided via NG_VALIDATORS or NG_ASYNC_VALIDATORS #271
Comments
@anteburazer There it is, Ante! You've found the single most weak point of current custom validators implementation. I've already tried to get my head around this. Is there any chance that you could exclude certain strings / LoC from mangling / uglifying? |
@anteburazer I guess, I've got a solution for you! You just need to exclude the function name from mangling:
|
@udos86 thanks for your help. I'm using Angular CLI and I don't have access to webpack config file. They provide some config file to override webpack configuration but as far as I know there's no option to manipulate with mangling options. My other problem is that I had to customize the library, because of some extra features I needed, so I included it as a regular module inside the project and not via node modules. I'm not sure how I can integrate your solution but it's up to me cause I branched from this repository because of custom modifications I had to make. I really appreciate your help. If you have any idea please let me know, if not I'll have to make some workaround for this. |
For all adventurers who wants to include this library as project's local module and not via node_modules this is how to workaround this issue:
I didn't cover async validators in this case. Maybe I will one day when I see red errors in production :) Enjoy :) |
@anteburazer Great! Thanks for figuring out that workaround! |
I too have ran into this problem. However, I didn't fork the repo, i'm using the latest version. Is the only workaround found so far is forking the repo and modifying |
@kirjai I'll try to figure out a solution for everyone out there using Angular CLI |
@kirjai @anteburazer Good news, everybody! I finally found a fix for this! Have a look at aaff8ec. However there's one constraint: It only works for And please always name your validator function the same as the property of it's return object:
|
@udos86 thanks for help. I didn't try your solution yet but I saw that Angular CLI supports webpack.config.js now: http://www.dzurico.com/angular-cli-with-the-super-powers/ @kirjai you can also try with Udo's first solution by excluding validator's name from mangling |
@anteburazer Alright, thanks for the information! |
i being pulling my hair over this issue but to no avail
i followed all the suggested methods but still not solved |
@ellipizle Hi! Did you update to |
For anyone on webpack 4
is the new way to achieve this |
I have a problem with custom validators but only when building application for production. The problem is in dynamic-form.service.ts file when code enters in getCustomValidatorFn() function.
I'm using Angular CLI with webpack: v1.0.0-beta.31
Angular v2.4.3
The problem appears when code gets uglified and variable names are renamed. Function getCustomValidatorFn() compares two strings which are not equal because of code uglification and because of that it doesn't find anything in NG_VALIDATORS array.
I hope the code below explains the problem. I put console.log() to output breaking lines of code to understand where the issue is. If it's not clear I will explain more clear.
Right now I'm not able to use the library in production.
Is there any solution to workaround this?
Thanks
The text was updated successfully, but these errors were encountered: