-
Notifications
You must be signed in to change notification settings - Fork 27.1k
FormValueControl min/max are limited to numbers, but date inputs allow these to be strings #65676
Description
Which @angular/* package(s) are relevant/related to the feature request?
forms
Description
The FormValueControl interface dictates the min/max signals be of type number, however the spec for these attributes allows them to be date strings for at least input[type=date] and input[type=time].
Aside from that, when migrating existing ControlValueAccessor to FormValueControl there seems to be no way to allow min/max attribute bindings that doesn't introduce breaking API changes. Changing the properties to be named something else with aliases min/max still violates the FormValueControl interface contract. See the example and compiler error produced below.
readonly minValue = input<string | null>(null, { alias: 'min' });
Type 'InputSignal<string | null>' is not assignable to type 'InputSignal<number | undefined>'
Perhaps I'm overlooking something, but I'm not seeing a way add non-numeric min/max attributes on a custom form control short of using an entirely different property and attribute name besides min or max.
Proposed solution
Allow us to specify our own types for the min/max properties. Arguably, they seem like they should be TValue | undefined from the FormControlValue interface.
Alternatives considered
Changing the internal properties for min/max to different names with aliased min/max attributes. This does not work, because it still violates the interface contract.
Metadata
Metadata
Assignees
Type
Projects
Status