core/forms/filter-non-array-validation-errors.pipe.ts
This pipe should be used in case when there might be generic Array validators, that could populate error object with errors that are directly related to array elements. Such errors should be handled separately, but there still might be errors that applies to whole array. This allows to filter out entry-specific messages from error object.
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
}
}
<small *ngFor="let error of errors | filterNonArrayValidationErrors | keyvalue">
{{error.key | humanizeValidationMessage | translate: error.value}}
</small>
Above code renders only these error messages that are not generated by Array entries.
Name | filterNonArrayValidationErrors |
transform | ||||||
transform(validationErrors: ArrayValidationErrors | ValidationErrors)
|
||||||
Parameters :
Returns :
ValidationErrors | null
|