-
Notifications
You must be signed in to change notification settings - Fork 26.2k
Get value of the validations applied to control. ie., minLegth or maxLength #48662
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
Comments
Had more or less the same problem a few days ago. Wanted to read the values of Validator.min and Validator.max.
My example when I needed to read the params of the min and max validators:
|
+1 this would be really useful |
Same problem here. |
+1, would also be really handy to be able to pass the value dynamically to translate strings for error messages etc. |
+1, ran into a similar issue today where I wanted to read the |
+1, exactly what carlos-ds said |
+1, for the same reasons given above. |
+1 again for the same reasons as above. |
+1, same reasons as above |
+1, for the same reasons given above. |
+1, same reasons as above |
+1 pls |
+1, how is this not even a feature yet 😟 |
I am not sure, but I think this could help solve many workarounds out there. |
+1 |
Which @angular/* package(s) are relevant/related to the feature request?
forms
Description
I'm developing a UI to display the counter next to the input field to show the
10/100
character count against the maximum value allowed.I have set
Validators.maxLength(100)
validation but there is no option to get the maximum value set for the validator.One way to do this is to set the maximum value statically but I want to keep it dynamic against the validation set for the control.
Proposed solution
The list of validators applied on a control could be exposed with metadata containing the set values for each validation.
This will be helpful in the runtime check for the validation value.
Alternatives considered
The validation and its value are exposed when an error occurs (validation fail) on the control. But this cannot be used in the counter because the value will be disclosed only when there is an error.
The text was updated successfully, but these errors were encountered: