The Wayback Machine - https://web.archive.org/web/20220321101741/https://github.com/angular/angular/pull/42978
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(forms): allow min/max validator to be bound to null #42978

Closed

Conversation

iRealNirmal
Copy link
Contributor

@iRealNirmal iRealNirmal commented Jul 28, 2021

If the validator is bound o be
ull then no validation occurs and attribute is not added to DOM.

PR already raised for minLength and maxLength valdiator (#42565).
Changes were discussed in #42378

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?

Null data type is not supported

Issue Number: #42267.

What is the new behavior?

Added support for null data type

Does this PR introduce a breaking change?

  • Yes
  • No

This is one of many PR which is going to be raised for adding support of null validation. One can go through conversation here
#42378 (comment)

Other information

@google-cla google-cla bot added the cla: yes label Jul 28, 2021
@pullapprove pullapprove bot requested a review from AndrewKushnir Jul 28, 2021
@iRealNirmal iRealNirmal marked this pull request as draft Jul 28, 2021
@iRealNirmal
Copy link
Contributor Author

@iRealNirmal iRealNirmal commented Jul 28, 2021

@AndrewKushnir I will be adding test cases as well once I get go ahead with current implementation.

@ngbot ngbot bot added this to the Backlog milestone Jul 28, 2021
@ngbot ngbot bot added this to the Backlog milestone Jul 28, 2021
Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

Thanks for creating this PR @iRealNirmal 👍

I've left a comment with a proposal to move the enabled logic into the base class, please let me know what you think. Thank you.

packages/forms/src/directives/validators.ts Outdated Show resolved Hide resolved
packages/forms/src/directives/validators.ts Outdated Show resolved Hide resolved
@AndrewKushnir AndrewKushnir requested a review from dylhunn Jul 28, 2021
@iRealNirmal iRealNirmal force-pushed the addNull-in-min-max-validator branch 3 times, most recently from e0c8e50 to 65783df Compare Aug 1, 2021
Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

Thanks for additional changes @iRealNirmal, please see my comments below.

I have done this changes just one dilemma here in // TODO: add docs as needed. you want me to add comment right?(You don't need to provide comment I just want to confirm) or you meant it to be added some where else?

Yes, we need to add docs for that function (in a similar way other AbstractValidatorDirective class methods are documented).

packages/forms/src/directives/validators.ts Outdated Show resolved Hide resolved
packages/forms/src/directives/validators.ts Outdated Show resolved Hide resolved
packages/forms/src/directives/validators.ts Outdated Show resolved Hide resolved
packages/forms/src/directives/validators.ts Outdated Show resolved Hide resolved
@iRealNirmal iRealNirmal force-pushed the addNull-in-min-max-validator branch from 65783df to 19191ef Compare Aug 6, 2021
Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

@iRealNirmal thanks for additional changes. I've left a few comments.

The general logic looks good, it'd be great to add tests to verify new behavior (based on the tests that you've added for MinLength and MaxLength validators in the previous PR).

packages/forms/src/directives/validators.ts Outdated Show resolved Hide resolved
packages/forms/src/directives/validators.ts Outdated Show resolved Hide resolved
packages/forms/src/directives/validators.ts Outdated Show resolved Hide resolved
@iRealNirmal
Copy link
Contributor Author

@iRealNirmal iRealNirmal commented Aug 11, 2021

test

Yes I will add test case as well, I was just waiting for our code approach to be finalised before writing test cases to prevent rewriting of it. I will add in next commit with suggested changes.

@iRealNirmal iRealNirmal force-pushed the addNull-in-min-max-validator branch 2 times, most recently from 3c5de3b to 51f828a Compare Aug 16, 2021
@iRealNirmal iRealNirmal marked this pull request as ready for review Aug 16, 2021
@iRealNirmal
Copy link
Contributor Author

@iRealNirmal iRealNirmal commented Aug 24, 2021

@AndrewKushnir can you please review it again once ?

@AndrewKushnir
Copy link
Contributor

@AndrewKushnir AndrewKushnir commented Sep 1, 2021

@iRealNirmal sorry for the delay! I will have a look at the changes within the next day or so and let you know. Thank you.

Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

@iRealNirmal I've added some comments, could you please have a look when you get a chance? It also seems like there is a merge conflict with the main branch. It'd be helpful to rebase and resolve conflicts, so that we can run extra tests in Google's codebase.

packages/forms/src/directives/validators.ts Outdated Show resolved Hide resolved
packages/forms/src/directives/validators.ts Outdated Show resolved Hide resolved
packages/forms/src/directives/validators.ts Outdated Show resolved Hide resolved
packages/forms/src/directives/validators.ts Outdated Show resolved Hide resolved
packages/forms/src/directives/validators.ts Outdated Show resolved Hide resolved
packages/forms/src/directives/validators.ts Outdated Show resolved Hide resolved
@iRealNirmal iRealNirmal force-pushed the addNull-in-min-max-validator branch 2 times, most recently from d113588 to 2a6ce84 Compare Sep 6, 2021
@AndrewKushnir
Copy link
Contributor

@AndrewKushnir AndrewKushnir commented Sep 8, 2021

FYI I've also started tests in Google's codebase (internal-only link) to see if there are some use-cases that we'd need to cover.

@pullapprove pullapprove bot requested a review from atscott Sep 23, 2021
…ng the value to `null`)

This commit updates the logic of the `min` and `max` validators to allow
disabling them dynamically in case `null` is provided as a value. For example: `<input
type="number" [min]="minValue">`, when `minValue` might be set to `null` in a
component class. This should allow `min` and `max` validators to be used for dynamic forms.

Note: similar support was added to the `minLength` and `maxLength`
validators earlier (see angular#42565).
Copy link
Contributor

@jessicajaniuk jessicajaniuk left a comment

LGTM 🍪
reviewed-for: public-api

@pullapprove pullapprove bot requested a review from jelbourn Sep 23, 2021
Copy link
Contributor

@IgorMinar IgorMinar left a comment

LGTM

Reviewed-for: public-api

@AndrewKushnir
Copy link
Contributor

@AndrewKushnir AndrewKushnir commented Sep 24, 2021

@iRealNirmal just want to let you know that this PR was merged and this feature will be included into Angular v13 release! 🎉

I also want to take this opportunity to say Thank You for the work that you did in this and other PRs! We made a few iterations on this change and you've addressed all the feedback and was very responsive. Thanks again for all your help!

@iRealNirmal
Copy link
Contributor Author

@iRealNirmal iRealNirmal commented Sep 25, 2021

@iRealNirmal just want to let you know that this PR was merged and this feature will be included into Angular v13 release! 🎉

I also want to take this opportunity to say Thank You for the work that you did in this and other PRs! We made a few iterations on this change and you've addressed all the feedback and was very responsive. Thanks again for all your help!

@AndrewKushnir thank you, thank you very much for your kind words and constant guidance, it was pleasure and fun working on it. Also am happy to give back community as am using angular since quite a long time and indirectly it helps to understand work being done by framework under the hood.

As next item I will work on remaining validators, also feel free to let me know if there is anything else you want me to take care.

@iRealNirmal iRealNirmal deleted the addNull-in-min-max-validator branch Sep 25, 2021
@AndrewKushnir
Copy link
Contributor

@AndrewKushnir AndrewKushnir commented Sep 25, 2021

@iRealNirmal thanks for the reply. If you get a chance to help, it'd be great to transition other validators (starting with minlength and maxlength) to use AbstractValidatorDirective as a base class, as you mentioned. Please let us know if you need any additional information, we'll be glad to help.

@iRealNirmal
Copy link
Contributor Author

@iRealNirmal iRealNirmal commented Sep 25, 2021

sure I will take care of it.

@angular-automatic-lock-bot
Copy link

@angular-automatic-lock-bot angular-automatic-lock-bot bot commented Oct 26, 2021

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 Oct 26, 2021
@iRealNirmal iRealNirmal restored the addNull-in-min-max-validator branch Oct 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants