Add a validator (and directive) for the step
input attribute
#42845
Labels
area: forms
feature: under consideration
Feature request for which voting has completed and the request is now under consideration
feature
Issue that requests a new feature
Milestone
Which @angular/* package(s) are relevant/releated to the feature request?
forms
Description
The
step
attribute (spec) adds basic HTML validation to an input.It checks wether the value matches a combination of base value and step, and can trigger a stepMismatch validation error.
Use-case:
The validation could help to enforce integer on inputs, instead of using
pattern="\d*"
(which has already its own validator)Proposed solution
We could introduce a validator to check a control's value against a step attribute
Draft code
We could also add an associated directive for at least the
type="number"
input.By default, if the attribute is absent, the input still has a default step, but in that case the directive would not activate (since no attribute)
However, this can break existing code since
step
should be explicitely givenany
as a value to prevent validation, and I'm not sure most users are aware of this.Alternatives considered
Let users implement their own step validation, or use the pattern validator for specific cases (such as integer enforcement).
The text was updated successfully, but these errors were encountered: