Have an access to 'formControlName' value inside a custom validation function
See original GitHub issueI’m submitting a … (check one with “x”)
[ ] bug report
[x] feature request
[ ] support request
Current behavior There is no way how to get the value of ‘formControlName’ inside a custom validation function to identify which control is beeing actually validated (model-driven forms) because the only parameter is (c: FormControl) and the actual API of ‘FormControl’ is:
_errors, _onChange, _parent, _pristine, _status, _statusChanges, _touched,
_value, _valueChanges, asyncValidator, dirty, errors, pending, pristine,
root, status, statusChanges, touched, untouched, valid, validator, value, valueChanges
Expected/desired behavior Be able to get ‘formControlName’ value inside a custom validation and generic function and use it as the identity of the actually validated control. It allows to have a dynamic set of validation rules for each control (for example in JSON syntax) that could be maintenated outside of the app code then.
What is the motivation / use case for changing the behavior? To be more flexible and minimize the code = reducing the number of custom validators.
Please tell us about your environment:
- Angular version: 2.0.0-rc.4
- Browser: [all]
- Language: [all]
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:7 (6 by maintainers)
@kara Thanks for info. I understand that my previous problem description was not enough. I still think that there are real cases (including our projects) where our vision will be beneficial.
I will return to this thema and open a new issue when I have enough free time to collect descriptions that would be good enough to explain and convince.
Of course I know but still the main problem remains and there is no solutions except many and many lines of code. So that is why a feature request was created because it is evident that a validator should know on which control he is running.