core/forms/humanize-validation-message.pipe.ts
This pipe is responsible for transforming validation error key to actual translatable that are defined in ValidationPattern class.
Example :<c8y-message>
{{ 'minLength' | humanizeValidationMessage }}
</c8y-message>
Above code renders corresponding validation message for minLength: "Should have at least {{ requiredLength }} characters"
It is possible to chain translate pipe:
Example :const errorData = { requiredLength: 5, actualLength: 1};
<div>
{{ 'minLength' | humanizeValidationMessage | translate: errorData }}
</div>
should render: "Should have at least 5 characters"
It is also possible to provide custom translation message. For example:
Example :const errorData = { requiredLength: 5, actualLength: 1 };
const customMessages = {
minLength: gettext("File name should have at least {{ requiredLength }} characters")
};
<div>
{{ 'minLength' | humanizeValidationMessage:customMessages | translate: errorData }}
</div>
should render: "File name should have at least 5 characters"
Name | humanizeValidationMessage |
transform | ||||||||||||
transform(errorName: string, customMessages: literal type)
|
||||||||||||
Parameters :
Returns :
string
|