UNPKG

@c8y/ngx-components

Version:

Angular modules for Cumulocity IoT applications

55 lines 1.68 kB
import { PipeTransform } from '@angular/core'; import * as i0 from "@angular/core"; /** * This pipe is responsible for transforming validation error key to actual translatable that * are defined in ValidationPattern class. * * ```html * <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: * * ```ts * const errorData = { requiredLength: 5, actualLength: 1}; * ``` * * ```html * <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: * * ```ts * const errorData = { requiredLength: 5, actualLength: 1 }; * const customMessages = { * minLength: gettext("File name should have at least {{ requiredLength }} characters") * }; * ``` * * ```html * <div> * {{ 'minLength' | humanizeValidationMessage:customMessages | translate: errorData }} * </div> * ``` * * should render: * "File name should have at least 5 characters" */ export declare class HumanizeValidationMessagePipe implements PipeTransform { transform(errorName: string, customMessages?: { [key: string]: string; }): string; static ɵfac: i0.ɵɵFactoryDeclaration<HumanizeValidationMessagePipe, never>; static ɵpipe: i0.ɵɵPipeDeclaration<HumanizeValidationMessagePipe, "humanizeValidationMessage", true>; } //# sourceMappingURL=humanize-validation-message.pipe.d.ts.map