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.

multi-valued input validation support #12996

Open
@danialfarid

Description

@danialfarid

ngModelController supports $setValidity(validationErrorKey, isValid) but isValid is a boolean which would not provide enough information if the model value consists of multiple values or an array of values.

Consider we have an <input type="file" multiple ng-model="files" ngf-max-size="1MB"> (from https://github.com/danialfarid/ng-file-upload) the validation will happen on a list of files and if SOME of them are invalid for example exceed the maximum file size then just setting the validity of max-size to true or false won't be enough since user has no clue which file is causing this error.

So I would suggest to allow an object instead of a boolean for $serValidity so for example for the above scenario I could call $setValidity('maxSize', [invalidFile1, invalidFile2, ...]) for the invalid files in user selection and the user can show the appropriate error on the form:

<i ng-repeat="invalidFile in form.file.$error.maxSize">File {{invalidFile.name}} is too big</i>

This could also be helpful in case the validation is a time consuming process and generate a list of errors or informative message on how to fix the error depending on the model value.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions