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

multi-valued input validation support #12996

Open
danialfarid opened this issue Oct 1, 2015 · 1 comment
Open

multi-valued input validation support #12996

danialfarid opened this issue Oct 1, 2015 · 1 comment

Comments

@danialfarid
Copy link

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.

@petebacondarwin
Copy link
Contributor

This kind of thing is on our radar - @Narretz has some ideas. Look for more info as we move into 1.6 development...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants