Skip to content

Angular custom validators priority #19851

@NourEddinKhanjar

Description

@NourEddinKhanjar

I'm submitting a...

[ ] Feature request

Current behavior

When i apply multiple custom validators directives on template driven forms input, i can not control the ordering of executing the validators.
For example:
"input type="number" ngModel requiredValidator onlyNumberValidator moreThanTenValidator "

I assumed that directives should never rely on priority:

https://stackoverflow.com/questions/35756253/controlling-order-of-directive-evaluation-in-angular-2

"Component directives may not use the following attributes:
priority and terminal. While Angular 1 components may use these, they are not used in Angular 2 and it is better not to write code that relies on them."

Expected behavior

Validators should execute in the same orders they declared on the DOM which means the requiredValidator should be the first executed one then the onlyNumberValidator and moreThanTenValidator.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions