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

feat(validations): add support to bind dir validators #11116

wants to merge 2 commits into from


Copy link

kara commented Aug 27, 2016

This PR builds on @tolemac's original PR to finish adding support for dir validators. He's done most of the work here; just putting on finishing touches.

r: @IgorMinar, @vsavkin

Summary: Previously, it wasn't possible to bind to validators like required, minlength, maxlength, and pattern in the DOM. If you did the following:

<input name="first" ngModel [required]="isRequired">

...regardless of the value of isRequired, validation would be run as if required were set. This is because the built-in validator directives weren't set up to respond to inputs and to re-run validation when those inputs changed. Now the above should work!

This change enables to bind the validations attributes `required`,
`minlength`, `maxlength` and `pattern`.

Closes: #10505, #7393
Copy link

googlebot commented Aug 27, 2016

We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm.

@@ -30,6 +30,7 @@ export abstract class NgControl extends AbstractControlDirective {

get validator(): ValidatorFn { return <ValidatorFn>unimplemented(); }
get asyncValidator(): AsyncValidatorFn { return <AsyncValidatorFn>unimplemented(); }
get rawValidators(): any[] { return unimplemented(); }

This comment has been minimized.

Copy link

vsavkin Aug 27, 2016


why any[]?

This comment has been minimized.

Copy link

kara Aug 27, 2016

Author Contributor

Oh, I think it should be Array<Validator|ValidatorFn>. I can update.

@kara kara force-pushed the kara:validatorbind branch 3 times, most recently from c50e004 to 3ea3e8e Aug 27, 2016
@@ -105,6 +105,8 @@ export class NgModel extends NgControl implements OnChanges,

get validator(): ValidatorFn { return composeValidators(this._validators); }

get rawValidators(): Array<Validator|ValidatorFn> { return this._validators || []; }

This comment has been minimized.

Copy link

vsavkin Aug 29, 2016


Why do we include only sync validators here?

Copy link

vsavkin commented Aug 29, 2016

We're doing it this way because we don't it to be a breaking change? I find it a bit weird to have three properties instead of two.

Cause we could have had two properties validators and asyncValidators and compose them elsewhere, but it would be a breaking change.

@kara kara force-pushed the kara:validatorbind branch 2 times, most recently from 614f7a4 to 14cd536 Aug 29, 2016
Copy link

angular-automatic-lock-bot bot commented Sep 14, 2019

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.