ngx-custom-validators
ngx-custom-validators copied to clipboard
[Feature Request] notEqualTo should include name of control
Similar to #12
Let's say we define a "password" validation like this:
password: ["", [Validators.required, CustomValidators.notEqualTo(email)]],
The notEqualTo validator's metadata includes the invalid value, so we can show this message:
'password' cannot equal '[email protected]'
But, this is not informative. It should include the name of the target control (email), so that we can do this instead:
'password' cannot equal 'email'
That makes more sense.
So passwordControl.errors should return: { control: {}, otherControlName: 'email' }
What's the goal?
To use the control name with a translation and display it to the user?
Yes, so you can use this:
'password' cannot equal 'email'
Otherwise you don't know which control (i.e. email) it equalled.