-
Notifications
You must be signed in to change notification settings - Fork 27k
Description
Which @angular/* package(s) are the source of the bug?
forms
Is this a regression?
No
Description
I am getting this error when trying to set the maxlength attribute directly in the template when using the [filed] directive.
Binding to '[maxlength]' is not allowed on nodes using the '[field]' directive
If a user copy and paste text into a input with field directive, and the text pasted has more character than the allowed by the maxLength validator, the text would be trimmed potentially without the user realizing that any trim happened. In this case I would prefer to have a maxlength validator of lets say 200 characters, and a maxlength attribute of 250. And if the user pastes anything greater than 250, it will trim at 250 but provide a error message so the user is aware of what happened.
I can see the benefit of trying to add the maxlength attribute automatically when the validator is used. But it can also get in the way in certain scenarios as described above.
Is the only option at the moment to create a custom validator so the maxlength attribute is not added by default?
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
Please provide the environment you discovered this bug in (run ng version)
Angular v 21.0.6
Anything else?
No response
Metadata
Metadata
Assignees
Type
Projects
Status