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

Loosen validator directives selectors #51248

Open
Xriuk opened this issue Aug 2, 2023 · 6 comments
Open

Loosen validator directives selectors #51248

Xriuk opened this issue Aug 2, 2023 · 6 comments
Assignees
Labels
action: global presubmit The PR is in need of a google3 global presubmit area: forms feature: insufficient votes Label to add when the not a sufficient number of votes or comments from unique authors feature Issue that requests a new feature forms: directives forms: validators
Milestone

Comments

@Xriuk
Copy link

Xriuk commented Aug 2, 2023

Which @angular/* package(s) are relevant/related to the feature request?

forms

Description

I have created few custom input components which are basically wrappers around other controls, and they could use validators like [min], [max], ... but I noticed that the selectors for MaxValidator are input[type=number][max][formControlName],input[type=number][max][formControl],input[type=number][max][ngModel] and this prohibits the usage on external components.

Proposed solution

Changing specific selectors to just [max][formControlName],[max][formControl],[max][ngModel] would allow using them everywhere. I have created a custom directive inheriting from the original directive and it works straight out of the box.

Alternatives considered

None

@pkozlowski-opensource
Copy link
Member

This is an interesting case. Currently the presence of the input in the directive selector makes sense since we've got a host binding to the max attribute - assuming that such attribute exists on a given element. We can't guarantee it in general.

Having said this other existing validator directives don't have the input restrictions and still bind to attributes that might not exists. So at least we've got inconsistency in our implementation.

@pkozlowski-opensource
Copy link
Member

Changing a selector to drop input is a potentially breaking change since the validator directives could start matching in places where they were not before. We need to better understand how real this problem is.

@pkozlowski-opensource pkozlowski-opensource added the action: global presubmit The PR is in need of a google3 global presubmit label Aug 2, 2023
@pkozlowski-opensource pkozlowski-opensource self-assigned this Aug 2, 2023
@pkozlowski-opensource pkozlowski-opensource added the feature Issue that requests a new feature label Aug 2, 2023
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Aug 2, 2023
@angular-robot angular-robot bot added the feature: votes required Feature request which is currently still in the voting phase label Aug 3, 2023
@angular-robot
Copy link
Contributor

angular-robot bot commented Aug 3, 2023

This feature request is now candidate for our backlog! In the next phase, the community has 60 days to upvote. If the request receives more than 20 upvotes, we'll move it to our consideration list.

You can find more details about the feature request process in our documentation.

@angular-robot
Copy link
Contributor

angular-robot bot commented Sep 12, 2023

Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.

Find more details about Angular's feature request process in our documentation.

@angular-robot
Copy link
Contributor

angular-robot bot commented Oct 2, 2023

Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.

We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.

You can find more details about the feature request process in our documentation.

@angular-robot angular-robot bot added feature: insufficient votes Label to add when the not a sufficient number of votes or comments from unique authors and removed feature: votes required Feature request which is currently still in the voting phase labels Oct 2, 2023
@JeanMeche
Copy link
Member

JeanMeche commented Jun 16, 2024

The solution for this is likely what #56226 proposes: allow to use the Validator directives as host directives.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action: global presubmit The PR is in need of a google3 global presubmit area: forms feature: insufficient votes Label to add when the not a sufficient number of votes or comments from unique authors feature Issue that requests a new feature forms: directives forms: validators
Projects
None yet
Development

No branches or pull requests

3 participants