Skip to content

Add support for min/max number validation in template driven forms. #23635

Closed

Description

@westonpace

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[X] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
[ ] Other... Please describe:

Current behavior

There is no mechanism for basic number validation (min/max) in template driven forms.

Expected behavior

<input type="number" [(ngModel)]="value" [minValue]="minimum" [maxValue]="maximum"/>

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Certainly the scope of validation should be pretty limited for Angular. However, the fact that #13688 was implemented seems to suggest that min/max are in this limited scope. This also would allow Angular to supply validators that at least match the HTML5 spec (sharing motivation with #16352 although this need not address that particular issue). Furthermore, there is some public demand as seen on StackOverflow and this has even been attempted and approved before but the mechanism used was a breaking change that had to be rolled back.

In order to avoid a breaking change it would seem that either custom attributes are used (easy but does not satisfy #16352) or the user has to add a particular module (or some other boolean flag) to enable the feature (adds complexity).

Environment


Angular version: X.Y.Z
5.2.10

Browser:
- [X] Chrome (desktop) version XX
- [X] Chrome (Android) version XX
- [X] Chrome (iOS) version XX
- [X] Firefox version XX
- [X] Safari (desktop) version XX
- [X] Safari (iOS) version XX
- [X] IE version XX
- [X] Edge version XX
 
For Tooling issues:
- Node version: N/A  
- Platform:  N/A 

Others:

Activity

  1. kara commented on May 1, 2018

    @kara
    Contributor

    The existing issue, #16352, encompasses this min/max validation case, so closing this as a dupe.

  2. added this to the needsTriage milestone on May 1, 2018
  3. angular-automatic-lock-bot commented on Sep 13, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  4. locked and limited conversation to collaborators on Sep 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions