angular: Regression caused by the min/max validators in 4.2.0

I’m submitting a … (check one with “x”)

[x] bug report
[ ] feature request
[ ] support request

Current behavior Version 4.2.0 introduces min and max validators. The issue arises when a custom component has min | max input property and that component implements ControlValueAccessor and is registered as a validator (custom validation logic requirements).

When the user wraps that component in a FormGroup the default min|max validators are always triggered and there is no way of instructing them that my component min, max properties are not meant to be validated.

This behavior will be also true if a custom component (which implements ControlValueAccessor) has input property that matches any of the built-in validator directives. For example if my custom component has input properties such as: min, max, minlength, maxlength etc.

Expected behavior There should be a way to suppress Angular validator directives for such properties if required by the component author.

Minimal reproduction of the problem with instructions Prior version 4.2.0 - http://plnkr.co/edit/QDoXhau2e1SuAuJ7tOwk?p=preview - no validation errors With version 4.2.0 - http://plnkr.co/edit/gqtdQqL7DlY0UC1H6M0R?p=preview - validation errors

What is the motivation / use case for changing the behavior? There should be mechanism for preventing Angular validator directives for input properties that matches built-in validation directives. These input properties might have a bit different meaning in the component context.

  • Angular version: 4.2.0

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 14
  • Comments: 16 (4 by maintainers)

Commits related to this issue

Most upvoted comments

For now, we are going to remove the exports for the min/max validator directives, as their addition is a breaking change. At the least, we should wait to add them until a major version. In the meantime, we will have further discussion about what the best solution is going forward for all validator directives.

BTW, a possible solution for this issue might be to use this selector instead, so that the directives work solely for an <input>: input[min][formControlName],input[min][formControl],input[min][ngModel]

Will min/max be introduced into the upcoming major version 5 or should we wait for the 6?

@kara Can the discussion regarding the validator directives be followed somewhere? I need to make a decision whether to wait for Angular solution or to implement something myself. Thank you!