Skip to content

Validator.minLength does not work with input type number #15053

Closed

Description

@pflopez

I'm submitting a ... (check one with "x")

[x ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

The build in validator for minLength works for input with type text, email, etc. However, its not working with type number. The value when inspecting valueChanges is a number, so I'm guessing its because number does not have a .length method.

Expected behavior

minLength validator should return true for any number which length in character count (number.toString() ?) is bigger than provided value, or false otherwise.

Minimal reproduction of the problem with instructions

Plunk with issue:
https://plnkr.co/edit/sAITWc?p=preview

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

The validator should work regardless of the type of input field used.

Please tell us about your environment:

Mac, chrome, npm.

  • Angular version: 2.0.X

2.4.0

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

only tested on chrome.

  • Language: [all | TypeScript X.X | ES6/7 | ES5]
    typescript
  • Node (for AoT issues): node --version =

Activity

  1. changed the title [-]Validators.minLength does not work with input type number[/-] [+]Validator.minLength does not work with input type number[/+] on Mar 9, 2017
  2. DzmitryShylovich commented on Mar 9, 2017

    @DzmitryShylovich
    Contributor

    You are looking for this #13688

  3. mhevery commented on Dec 19, 2017

    @mhevery
    Contributor

    resolved #13688

  4. 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.

  5. 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

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions