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.

ngRequired: suggest mark empty arrays as invalid  #2365

Closed
@gorkunov

Description

@gorkunov

Current validator in the ngRequired directive looks like:

var validator = function(value) {
  if (attr.required && (isEmpty(value) || value === false)) {
      ctrl.$setValidity('required', false);
      return;
  } else {
      ctrl.$setValidity('required', true);
      return value;
  }
};

Value checked by isEmpty function which returns true for empty arrays.

if (attr.required && (isEmpty(value) || value === false)) {

I think that [] should be marked as invalid for this case.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions