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

@yogeshgadge

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
  }

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions