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

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
4 participants
@kara
Contributor

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!

feat(validations): add support to bind validation attributes
This change enables to bind the validations attributes `required`,
`minlength`, `maxlength` and `pattern`.

Closes: #10505, #7393
@googlebot

This comment has been minimized.

Show comment
Hide comment
@googlebot

googlebot 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.

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.

Show outdated Hide outdated modules/@angular/forms/src/directives/ng_control.ts
@@ -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.

@vsavkin

vsavkin Aug 27, 2016

Contributor

why any[]?

@vsavkin

vsavkin Aug 27, 2016

Contributor

why any[]?

This comment has been minimized.

@kara

kara Aug 27, 2016

Contributor

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

@kara

kara Aug 27, 2016

Contributor

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

Show outdated Hide outdated modules/@angular/forms/src/directives/ng_model.ts
@@ -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.

@vsavkin

vsavkin Aug 29, 2016

Contributor

Why do we include only sync validators here?

@vsavkin

vsavkin Aug 29, 2016

Contributor

Why do we include only sync validators here?

@vsavkin

This comment has been minimized.

Show comment
Hide comment
@vsavkin

vsavkin Aug 29, 2016

Contributor

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.

Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment