You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
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.
The text was updated successfully, but these errors were encountered:
ngModelController
supports$setValidity(validationErrorKey, isValid)
butisValid
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 ofmax-size
totrue
orfalse
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: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.
The text was updated successfully, but these errors were encountered: