File

core/forms/extract-array-validation-errors.pipe.ts

Description

This pipe should be used in pair with validateArrayElements function - it allows to distribute errors for each position in array, from the object prepared by validateArrayElements.

Example :
errors = {
 "INNER_ARRAY_ERROR_minlength": {
   isArrayError: true,
   originalKey: "minlength",
   entries: [
     {
       index: 0,
       errorData: {
       requiredLength: 5,
       actualLength: 4
       }
     },
     {
       index: 2,
       errorData: {
         requiredLength: 5,
         actualLength: 3
       }
     },
   ]
 },
 "minlength": {
   requiredLength: 5,
   actualLength: 3
 }
}
Example :
<small *ngFor="let error of errors | extractArrayValidationErrors:index | keyvalue">
 {{ error.key | humanizeValidationMessage | translate: error.value }}
</small>

Above code renders only these error messages that are generated by Array entries.

Metadata

Methods

transform
transform(validationErrors: ArrayValidationErrors | ValidationErrors | null, index: number)
Parameters :
Name Type Optional
validationErrors ArrayValidationErrors | ValidationErrors | null No
index number No
Returns : ValidationErrors | null

results matching ""

    No results matching ""