Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

"minValidator" does not make sense as a formatter. Input number "min" does not show initial value when it is invalid #8264

Closed

Description

@yogeshgadge

Problem

Initial invalid values are lost in the Form when $dirty is false.

http://jsfiddle.net/PK3QH/7/

Scenario

You are displaying a Form intending to show fields with proper validation e.g. min=10 for .

The model returns a number 3 as what was probably saved prior say in some database. Or your business rules have changed and the min value now must be 10 but it was say min=2 in the previous release of your application.

Possible diagnosis

e.g.

minValidator
  if (attr.min) {
    var minValidator = function(value) {
      var min = parseFloat(attr.min);
      return validate(ctrl, 'min', ctrl.$isEmpty(value) || value >= min, value);
    };

    ctrl.$parsers.push(minValidator);
    ctrl.$formatters.push(minValidator); //I wonder if you really need this
    ///all you need is a number validator
  }

Activity

  1. caitp commented on Jul 18, 2014

    @caitp
    Contributor

    The fact is, none of the validation really belongs in parsers or formatters. Validation and parsing/formatting are really separate operations.

    Anyhow, this is being worked on, thanks for sharing the pain of the current validation stuff =)

  2. self-assigned this
    on Jul 21, 2014
  3. IgorMinar commented on Jul 21, 2014

    @IgorMinar
    Contributor

    @matsko can you add this as a test case to your refactoring branch and close this issue please?

  4. added this to the milestone on Jul 21, 2014
  5. IgorMinar commented on Jul 21, 2014

    @IgorMinar
    Contributor

    @yogeshgadge fyi, please watch #6928

  6. Narretz commented on Sep 5, 2014

    @Narretz
    Contributor

    This is fixed in master: http://jsfiddle.net/PK3QH/24/

    This is won't fix in 1.2.x afaik, because validation via parsers is too rigid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions