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

[Feature Request] notEqualTo should include name of control #23

Open
lonix1 opened this issue Jun 12, 2019 · 2 comments
Open

[Feature Request] notEqualTo should include name of control #23

lonix1 opened this issue Jun 12, 2019 · 2 comments

Comments

@lonix1
Copy link

lonix1 commented Jun 12, 2019

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' }

@rsaenen
Copy link
Owner

rsaenen commented Jun 13, 2019

What's the goal?

To use the control name with a translation and display it to the user?

@lonix1
Copy link
Author

lonix1 commented Jun 13, 2019

Yes, so you can use this:

'password' cannot equal 'email'

Otherwise you don't know which control (i.e. email) it equalled.

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