Skip to content

fix(forms): accept number length in length validators#32057

Closed
cexbrayat wants to merge 1 commit intoangular:masterfrom
cexbrayat:feat/ivy-maxlength
Closed

fix(forms): accept number length in length validators#32057
cexbrayat wants to merge 1 commit intoangular:masterfrom
cexbrayat:feat/ivy-maxlength

Conversation

@cexbrayat
Copy link
Copy Markdown
Member

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Both MinLengthValidator and MaxLengthValidator accepted only string inputs for the length required, which throws with Ivy and fullTemplateTypeCheck enabled:

<!-- min = 2 in the component -->
<input [minlength]="min">

with:

Type 'number' is not assignable to type 'string | undefined'

What is the new behavior?

This relaxes the accepted type to string | number to avoid breakage when developers switch to Ivy and fTTC.

Does this PR introduce a breaking change?

  • Yes
  • No

If someone extends one of these validators in their own code, then yes, they'll have to pdate the type of the minlength/maxlength field.

Other information

@cexbrayat cexbrayat requested review from a team August 8, 2019 17:16
@googlebot
Copy link
Copy Markdown

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@googlebot
Copy link
Copy Markdown

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: yes and removed cla: no labels Aug 8, 2019
@cexbrayat cexbrayat force-pushed the feat/ivy-maxlength branch from 177ba2c to 649ffdc Compare August 8, 2019 18:14
@ngbot ngbot bot added this to the needsTriage milestone Aug 8, 2019
@kara kara added breaking changes action: presubmit The PR is in need of a google3 presubmit action: review The PR is still awaiting reviews from at least one requested reviewer target: major This PR is targeted for the next major release labels Aug 29, 2019
@kara
Copy link
Copy Markdown
Contributor

kara commented Aug 29, 2019

VE presubmit

global TAP

@mhevery mhevery added action: merge The PR is ready for merge by the caretaker and removed action: presubmit The PR is in need of a google3 presubmit action: review The PR is still awaiting reviews from at least one requested reviewer labels Nov 8, 2019
@ngbot
Copy link
Copy Markdown

ngbot bot commented Nov 8, 2019

I see that you just added the PR action: merge label, but the following checks are still failing:
    failure status "ci-codefresh-bazel" is failing

If you want your PR to be merged, it has to pass all the CI checks.

If you can't get the PR to a green state due to flakes or broken master, please try rebasing to master and/or restarting the CI job. If that fails and you believe that the issue is not due to your change, please contact the caretaker and ask for help.

@mhevery mhevery force-pushed the feat/ivy-maxlength branch from 649ffdc to 0b85cd2 Compare November 8, 2019 17:14
@mhevery
Copy link
Copy Markdown
Contributor

mhevery commented Nov 8, 2019

presubmit

@kara kara added the action: presubmit The PR is in need of a google3 presubmit label Nov 9, 2019
@alxhub alxhub added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews and removed action: presubmit The PR is in need of a google3 presubmit labels Nov 12, 2019
@cexbrayat cexbrayat changed the title feat(forms): accept number length in length validators fix(forms): accept number length in length validators Nov 12, 2019
@alxhub alxhub removed the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Nov 12, 2019
@alxhub alxhub added target: patch This PR is targeted for the next patch release and removed target: major This PR is targeted for the next major release labels Nov 12, 2019
@IgorMinar IgorMinar modified the milestones: needsTriage, v10-candidates Nov 27, 2019
@atscott
Copy link
Copy Markdown
Contributor

atscott commented Jan 13, 2020

presubmit

Both `MinLengthValidator` and `MaxLengthValidator` accepted only string inputs for the length required, which throws with Ivy and `fullTemplateTypeCheck` enabled:

    <!-- min = 2 in the component -->
    <input [minlength]="min">

with:

    Type 'number' is not assignable to type 'string | undefined'

This relaxes the accepted type to `string | number` to avoid breakage when developers switch to Ivy and fTTC.
@atscott atscott force-pushed the feat/ivy-maxlength branch from f96e98d to 8dd6d47 Compare January 13, 2020 22:14
Copy link
Copy Markdown
Contributor

@AndrewKushnir AndrewKushnir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change LGTM, but I think we need to check whether it should go to v9 or v10. Thank you.

@AndrewKushnir
Copy link
Copy Markdown
Contributor

FYI, I've put "blocked" label for now to make sure that we merge it once the decision is made on when this PR should be merged (v9 or v10).

Copy link
Copy Markdown
Contributor

@IgorMinar IgorMinar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm for api change. this is minor enough that it can go to v9.0.

thanks @cexbrayat!

@IgorMinar
Copy link
Copy Markdown
Contributor

For the record, we don't consider this to be a breaking change for public api, because we discourage people from extend our classes unless we documented that the class is meant to be subclassed:

extending any of our classes unless the support for this is specifically documented in the API docs
from: https://github.com/angular/angular/blob/master/docs/PUBLIC_API.md

@atscott atscott closed this in 9ceee07 Jan 14, 2020
atscott pushed a commit that referenced this pull request Jan 14, 2020
Both `MinLengthValidator` and `MaxLengthValidator` accepted only string inputs for the length required, which throws with Ivy and `fullTemplateTypeCheck` enabled:

    <!-- min = 2 in the component -->
    <input [minlength]="min">

with:

    Type 'number' is not assignable to type 'string | undefined'

This relaxes the accepted type to `string | number` to avoid breakage when developers switch to Ivy and fTTC.

PR Close #32057
@angular-automatic-lock-bot
Copy link
Copy Markdown

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 Feb 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: forms cla: yes target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants