@lagoshny/ngx-validation-messages 19.0.0 → 20.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/lagoshny-ngx-validation-messages.mjs +15 -17
- package/fesm2022/lagoshny-ngx-validation-messages.mjs.map +1 -1
- package/index.d.ts +138 -3
- package/package.json +1 -1
- package/lib/components/ngx-custom-message/ngx-custom-message.component.d.ts +0 -20
- package/lib/components/ngx-validation-messages/ngx-validation-messages.component.d.ts +0 -40
- package/lib/directivies/ngx-validator-name.directive.d.ts +0 -25
- package/lib/interface/ngx-validation-messages.config.d.ts +0 -17
- package/lib/ngx-validation-messages.providers.d.ts +0 -7
- package/lib/service/ngx-validation-messages.service.d.ts +0 -37
- package/public-api.d.ts +0 -1
|
@@ -22,13 +22,13 @@ class NgxCustomMessageComponent {
|
|
|
22
22
|
* Contains overridden message for validator.
|
|
23
23
|
*/
|
|
24
24
|
message;
|
|
25
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
26
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "
|
|
25
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: NgxCustomMessageComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
26
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.15", type: NgxCustomMessageComponent, isStandalone: true, selector: "ngx-custom-message", inputs: { validatorName: ["forValidator", "validatorName"] }, viewQueries: [{ propertyName: "message", first: true, predicate: ["message"], descendants: true }], ngImport: i0, template: `
|
|
27
27
|
<div #message>
|
|
28
28
|
<ng-content></ng-content>
|
|
29
|
-
</div>`, isInline: true
|
|
29
|
+
</div>`, isInline: true });
|
|
30
30
|
}
|
|
31
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
31
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: NgxCustomMessageComponent, decorators: [{
|
|
32
32
|
type: Component,
|
|
33
33
|
args: [{
|
|
34
34
|
standalone: true,
|
|
@@ -37,9 +37,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImpo
|
|
|
37
37
|
<div #message>
|
|
38
38
|
<ng-content></ng-content>
|
|
39
39
|
</div>`,
|
|
40
|
-
imports: [
|
|
41
|
-
CommonModule,
|
|
42
|
-
]
|
|
40
|
+
imports: []
|
|
43
41
|
}]
|
|
44
42
|
}], propDecorators: { validatorName: [{
|
|
45
43
|
type: Input,
|
|
@@ -73,10 +71,10 @@ class NgxValidatorNameDirective {
|
|
|
73
71
|
ngAfterViewInit() {
|
|
74
72
|
this.message = this.elem.nativeElement.innerText;
|
|
75
73
|
}
|
|
76
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
77
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "
|
|
74
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: NgxValidatorNameDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
75
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.15", type: NgxValidatorNameDirective, isStandalone: true, selector: "[ngxValidatorName]", inputs: { validatorName: "validatorName" }, ngImport: i0 });
|
|
78
76
|
}
|
|
79
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
77
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: NgxValidatorNameDirective, decorators: [{
|
|
80
78
|
type: Directive,
|
|
81
79
|
args: [{
|
|
82
80
|
standalone: true,
|
|
@@ -146,10 +144,10 @@ class NgxValidationMessagesService {
|
|
|
146
144
|
return m && typeof m === 'object' ? m[i] : '';
|
|
147
145
|
}, obj);
|
|
148
146
|
}
|
|
149
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
150
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
147
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: NgxValidationMessagesService, deps: [{ token: NGX_VALIDATION_MESSAGES_CONFIG }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
148
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: NgxValidationMessagesService, providedIn: 'root' });
|
|
151
149
|
}
|
|
152
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
150
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: NgxValidationMessagesService, decorators: [{
|
|
153
151
|
type: Injectable,
|
|
154
152
|
args: [{
|
|
155
153
|
providedIn: 'root',
|
|
@@ -242,15 +240,15 @@ class NgxValidationMessagesComponent {
|
|
|
242
240
|
: this.formControl.errors[msg.validatorName] = { customMessage: message };
|
|
243
241
|
});
|
|
244
242
|
}
|
|
245
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
246
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "
|
|
243
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: NgxValidationMessagesComponent, deps: [{ token: NGX_VALIDATION_MESSAGES_CONFIG }, { token: NgxValidationMessagesService }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
244
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.15", type: NgxValidationMessagesComponent, isStandalone: true, selector: "ngx-validation-messages, [ngxValidationMessages]", inputs: { formControl: ["for", "formControl"] }, queries: [{ propertyName: "customMsgComponent", predicate: NgxCustomMessageComponent }, { propertyName: "customMsgDirective", predicate: NgxValidatorNameDirective }], ngImport: i0, template: "<!--To show error messages standalone without component-->\n@if (!formControl && customMsgComponent.length == 0 && customMsgDirective.length == 0) {\n <div\n [ngClass]=\"ngxValidationConfig?.validationMessagesStyle?.blockClassNames || 'ngx_vm__def_error_block'\">\n <span [ngClass]=\"ngxValidationConfig?.validationMessagesStyle?.textClassNames || 'ngx_vm__def_error_text'\">\n <ng-content></ng-content>\n </span>\n </div>\n}\n\n@if (errorMessages.length > 0) {\n <!--To show error messages in material ui style-->\n @if (isMaterialError) {\n @for (message of errorMessages; track message) {\n <mat-error>{{ message }}</mat-error>\n }\n } @else {\n <div [ngClass]=\"ngxValidationConfig?.validationMessagesStyle?.blockClassNames || 'ngx_vm__def_error_block'\">\n @for (message of errorMessages; track message) {\n <div>\n <span [ngClass]=\"ngxValidationConfig?.validationMessagesStyle?.textClassNames || 'ngx_vm__def_error_text'\">\n {{ message }}\n </span>\n </div>\n }\n </div>\n }\n <!--To show error messages in user style-->\n}\n", styles: [".ngx_vm__def_error_block{position:relative;display:inline-block;width:100%;margin-bottom:10px;margin-top:2px;padding:8px;border-radius:0;background:#c51244;box-shadow:1px 1px 1px #aaa;opacity:.8}.ngx_vm__def_error_text{color:#fff}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "ngmodule", type: MatFormFieldModule }, { kind: "directive", type: i3.MatError, selector: "mat-error, [matError]", inputs: ["id"] }] });
|
|
247
245
|
}
|
|
248
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
246
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: NgxValidationMessagesComponent, decorators: [{
|
|
249
247
|
type: Component,
|
|
250
248
|
args: [{ standalone: true, selector: 'ngx-validation-messages, [ngxValidationMessages]', imports: [
|
|
251
249
|
CommonModule,
|
|
252
250
|
MatFormFieldModule,
|
|
253
|
-
], template: "<!--To show error messages standalone without component-->\n
|
|
251
|
+
], template: "<!--To show error messages standalone without component-->\n@if (!formControl && customMsgComponent.length == 0 && customMsgDirective.length == 0) {\n <div\n [ngClass]=\"ngxValidationConfig?.validationMessagesStyle?.blockClassNames || 'ngx_vm__def_error_block'\">\n <span [ngClass]=\"ngxValidationConfig?.validationMessagesStyle?.textClassNames || 'ngx_vm__def_error_text'\">\n <ng-content></ng-content>\n </span>\n </div>\n}\n\n@if (errorMessages.length > 0) {\n <!--To show error messages in material ui style-->\n @if (isMaterialError) {\n @for (message of errorMessages; track message) {\n <mat-error>{{ message }}</mat-error>\n }\n } @else {\n <div [ngClass]=\"ngxValidationConfig?.validationMessagesStyle?.blockClassNames || 'ngx_vm__def_error_block'\">\n @for (message of errorMessages; track message) {\n <div>\n <span [ngClass]=\"ngxValidationConfig?.validationMessagesStyle?.textClassNames || 'ngx_vm__def_error_text'\">\n {{ message }}\n </span>\n </div>\n }\n </div>\n }\n <!--To show error messages in user style-->\n}\n", styles: [".ngx_vm__def_error_block{position:relative;display:inline-block;width:100%;margin-bottom:10px;margin-top:2px;padding:8px;border-radius:0;background:#c51244;box-shadow:1px 1px 1px #aaa;opacity:.8}.ngx_vm__def_error_text{color:#fff}\n"] }]
|
|
254
252
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
255
253
|
type: Inject,
|
|
256
254
|
args: [NGX_VALIDATION_MESSAGES_CONFIG]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lagoshny-ngx-validation-messages.mjs","sources":["../../../projects/ngx-validation-messages/src/lib/interface/ngx-validation-messages.config.ts","../../../projects/ngx-validation-messages/src/lib/components/ngx-custom-message/ngx-custom-message.component.ts","../../../projects/ngx-validation-messages/src/lib/directivies/ngx-validator-name.directive.ts","../../../projects/ngx-validation-messages/src/lib/service/ngx-validation-messages.service.ts","../../../projects/ngx-validation-messages/src/lib/components/ngx-validation-messages/ngx-validation-messages.component.ts","../../../projects/ngx-validation-messages/src/lib/components/ngx-validation-messages/ngx-validation-messages.component.html","../../../projects/ngx-validation-messages/src/lib/ngx-validation-messages.providers.ts","../../../projects/ngx-validation-messages/src/public-api.ts","../../../projects/ngx-validation-messages/src/lagoshny-ngx-validation-messages.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\n\nexport const NGX_VALIDATION_MESSAGES_CONFIG: InjectionToken<NgxValidationMessagesConfig>\n = new InjectionToken<NgxValidationMessagesConfig>('NgxValidationMessagesConfig');\n\nexport interface NgxValidationMessagesConfig {\n\n /**\n * Object contains validation messages in validatorName: validatorMessage format.\n */\n messages: {\n [validatorName: string]: string;\n };\n\n /**\n * Define custom styles to display validation messages.\n */\n validationMessagesStyle?: {\n blockClassNames?: string;\n textClassNames?: string;\n };\n\n}\n","import { Component, ElementRef, Input, ViewChild } from '@angular/core';\nimport { CommonModule } from '@angular/common';\n\n/**\n * Component allows specifying custom validation message for the specified\n * validator to override default message.\n *\n * Use this component as child in {@link NgxValidationMessagesComponent}.\n */\n@Component({\n standalone: true,\n selector: 'ngx-custom-message',\n template: `\n <div #message>\n <ng-content></ng-content>\n </div>`,\n imports: [\n CommonModule,\n ]\n})\nexport class NgxCustomMessageComponent {\n\n /**\n * The name of the validator for which you want to override the message.\n */\n @Input('forValidator')\n public validatorName: string;\n\n /**\n * Contains overridden message for validator.\n */\n @ViewChild('message')\n public message: ElementRef;\n\n}\n","import { AfterViewInit, Directive, ElementRef, Input } from '@angular/core';\n\n/**\n * Allows to specify custom validator message to override default message.\n *\n * It's alternative for {@link NgxCustomMessageComponent}.\n * If you want to use standard html tags to define custom message, use this directive on html tag within\n * {@link NgxValidationMessagesComponent} specifying validator name as directive parameter,\n * otherwise use {@link NgxCustomMessageComponent}.\n */\n@Directive({\n standalone: true,\n selector: '[ngxValidatorName]'\n})\nexport class NgxValidatorNameDirective implements AfterViewInit {\n\n /**\n * The name of the validator for which you want to override the message.\n */\n @Input()\n public validatorName: string;\n\n /**\n * Contains overridden message for validator.\n */\n public message: string;\n\n constructor(private elem: ElementRef) {\n }\n\n public ngAfterViewInit(): void {\n this.message = this.elem.nativeElement.innerText;\n }\n\n}\n","import { Inject, Injectable } from '@angular/core';\nimport { NGX_VALIDATION_MESSAGES_CONFIG, NgxValidationMessagesConfig } from '../interface/ngx-validation-messages.config';\n\n/**\n * Service allows getting validation messages from client's settings.\n * Injecting {@link NgxValidationMessagesConfig} to get client's configuration with validation messages.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class NgxValidationMessagesService {\n\n public static SERVER_ERRORS = 'serverErrors';\n\n /**\n * Regular expression to find params placeholder '#[paramName]'.\n */\n private paramsRegExp = new RegExp(/#[[a-zA-Z_\\\\-]*]/);\n\n constructor(@Inject(NGX_VALIDATION_MESSAGES_CONFIG) private messagesConfig: NgxValidationMessagesConfig) {\n }\n\n /**\n * Get validation message for specified validator.\n *\n * @param validatorName for which to get message\n * @param params passed from validator for more detailed validation message\n *\n * @returns string validation message\n */\n public getValidatorErrorMessages(validatorName: string, params?: object): string {\n const validationMessages = this.messagesConfig.messages;\n const validationMessage: string = validationMessages[validatorName];\n\n if (!validationMessage) {\n throw new Error('Validation message for validator: ' + validatorName\n + ' cannot be found, please check validation message key for validator it is case sensitive.');\n }\n\n if (params) {\n return this.expandParameterizedTemplateMessage(validationMessage, params);\n }\n\n return validationMessage;\n }\n\n public expandParameterizedTemplateMessage(msg: string, params: object): string {\n while (this.paramsRegExp.test(msg)) {\n const foundParams = this.paramsRegExp.exec(msg);\n foundParams.forEach(value => {\n const paramPlaceholder = value;\n value = value.replace('#[', '').replace(']', '');\n msg = msg.replace(paramPlaceholder, this.getParameter(params, value));\n });\n }\n\n return msg;\n }\n\n /**\n * A utilitarian method to get a property from an object.\n * if there is no property, an empty string is returned.\n *\n * @param obj from which the property must be obtained\n * @param prop property name\n *\n * @return property value or empty string\n */\n private getParameter(obj: object, prop: string): string {\n return prop.split('.')\n .reduce((m, i) => {\n return m && typeof m === 'object' ? m[i] : '';\n }, obj);\n }\n\n // public static applyServerError(control: AbstractControl | null, serverError: ServerError): void {\n // if (!control) {\n // return;\n // }\n // if (control.getError(NgxValidationMessagesService.SERVER_ERRORS)) {\n // const existingErrorMessages = control.getError(NgxValidationMessagesService.SERVER_ERRORS);\n // if (_.isArray(existingErrorMessages.customMessages) &&\n // existingErrorMessages.customMessages.indexOf(serverError.message) === -1) {\n // existingErrorMessages.customMessages.push(serverError.message);\n // }\n // } else {\n // control.setErrors({[NgxValidationMessagesService.SERVER_ERRORS]: {customMessages: [serverError.message]}});\n // }\n // control.markAsTouched();\n // }\n\n}\n","import { AfterViewInit, Component, ContentChildren, ElementRef, Inject, Input, QueryList } from '@angular/core';\nimport { NgxValidatorNameDirective } from '../../directivies/ngx-validator-name.directive';\nimport {\n NGX_VALIDATION_MESSAGES_CONFIG,\n NgxValidationMessagesConfig\n} from '../../interface/ngx-validation-messages.config';\nimport { NgxValidationMessagesService } from '../../service/ngx-validation-messages.service';\nimport { NgxCustomMessageComponent } from '../ngx-custom-message/ngx-custom-message.component';\nimport { CommonModule } from '@angular/common';\nimport { MatFormFieldModule } from '@angular/material/form-field';\n\n/**\n * Component for displaying validation messages, supports child components of type {@link NgxCustomMessageComponent}\n * and html elements with directive {@link NgxValidatorNameDirective} to override validation messages.\n */\n@Component({\n standalone: true,\n selector: 'ngx-validation-messages, [ngxValidationMessages]',\n templateUrl: './ngx-validation-messages.component.html',\n styleUrls: ['./ngx-validation-messages.component.scss'],\n imports: [\n CommonModule,\n MatFormFieldModule,\n ]\n})\nexport class NgxValidationMessagesComponent implements AfterViewInit {\n\n /**\n * Form control for which need to show validation messages.\n */\n @Input('for')\n public formControl: any;\n\n /**\n * Contains {@link NgxCustomMessageComponent} if present.\n */\n @ContentChildren(NgxCustomMessageComponent)\n public customMsgComponent: any;\n\n /**\n * Contains {@link NgxValidatorNameDirective} if present.\n */\n @ContentChildren(NgxValidatorNameDirective)\n public customMsgDirective: any;\n\n public isMaterialError = false;\n\n /**\n * Key to get default validation message.\n */\n private defaultError = 'error';\n\n private materialErrorElement = 'MAT-ERROR';\n\n constructor(@Inject(NGX_VALIDATION_MESSAGES_CONFIG) public ngxValidationConfig: NgxValidationMessagesConfig,\n private ngxValidationMessagesService: NgxValidationMessagesService,\n private directiveElementRef: ElementRef) {\n }\n\n public ngAfterViewInit(): void {\n if (this.directiveElementRef && this.directiveElementRef.nativeElement\n && this.directiveElementRef.nativeElement.nodeName) {\n this.isMaterialError = this.materialErrorElement.toLocaleUpperCase()\n === this.directiveElementRef.nativeElement.nodeName.toLocaleUpperCase();\n }\n }\n\n /**\n * Get all validation messages for specified form control.\n */\n public get errorMessages(): Array<string> {\n const result: Array<string> = [];\n\n if (!this.formControl || !this.formControl.errors) {\n return result;\n }\n if (this.customMsgComponent && this.customMsgComponent.length > 0) {\n this.processingCustomMessages(this.customMsgComponent);\n }\n if (this.customMsgDirective && this.customMsgDirective.length > 0) {\n this.processingCustomMessages(this.customMsgDirective);\n }\n\n for (const property in this.formControl.errors) {\n if (this.formControl.errors.hasOwnProperty(property)\n && (this.formControl.touched || this.formControl.dirty)) {\n if (this.formControl.errors[property].customMessages instanceof Array) {\n result.push(...this.formControl.errors[property].customMessages);\n continue;\n }\n if (this.formControl.errors[property].customMessage) {\n result.push(this.formControl.errors[property].customMessage);\n continue;\n }\n const validationMessage: string =\n this.ngxValidationMessagesService.getValidatorErrorMessages(property, this.formControl.errors[property]);\n result.push(validationMessage || this.formControl.errors[property].message\n || this.ngxValidationMessagesService.getValidatorErrorMessages(this.defaultError));\n }\n }\n return result;\n }\n\n private processingCustomMessages(customMessage: QueryList<any>): void {\n customMessage.forEach((msg: any) => {\n if (!this.formControl.errors[msg.validatorName]) {\n return;\n }\n let message = (msg instanceof NgxCustomMessageComponent)\n ? msg.message.nativeElement.innerText : msg.message;\n message = this.ngxValidationMessagesService.expandParameterizedTemplateMessage(message, this.formControl.errors[msg.validatorName]);\n\n typeof this.formControl.errors[msg.validatorName] === 'object'\n ? this.formControl.errors[msg.validatorName].customMessage = message\n : this.formControl.errors[msg.validatorName] = {customMessage: message};\n });\n }\n\n}\n","<!--To show error messages standalone without component-->\n<div *ngIf=\"!formControl && customMsgComponent.length == 0 && customMsgDirective.length == 0\"\n [ngClass]=\"ngxValidationConfig?.validationMessagesStyle?.blockClassNames || 'ngx_vm__def_error_block'\">\n <span [ngClass]=\"ngxValidationConfig?.validationMessagesStyle?.textClassNames || 'ngx_vm__def_error_text'\">\n <ng-content></ng-content>\n </span>\n</div>\n\n<ng-container *ngIf=\"errorMessages.length > 0\">\n\n <!--To show error messages in material ui style-->\n <ng-container *ngIf=\"isMaterialError; else withoutMaterial\">\n <ng-container *ngFor=\"let message of errorMessages\">\n <mat-error>{{ message }}</mat-error>\n </ng-container>\n </ng-container>\n\n <!--To show error messages in user style-->\n <ng-template #withoutMaterial>\n <div [ngClass]=\"ngxValidationConfig?.validationMessagesStyle?.blockClassNames || 'ngx_vm__def_error_block'\">\n <div *ngFor=\"let message of errorMessages\">\n <span [ngClass]=\"ngxValidationConfig?.validationMessagesStyle?.textClassNames || 'ngx_vm__def_error_text'\">\n {{ message }}\n </span>\n </div>\n </div>\n </ng-template>\n\n</ng-container>\n","import { Provider } from '@angular/core';\r\nimport { NGX_VALIDATION_MESSAGES_CONFIG, NgxValidationMessagesConfig } from './interface/ngx-validation-messages.config';\r\n\r\nexport {NGX_VALIDATION_MESSAGES_CONFIG, NgxValidationMessagesConfig} from './interface/ngx-validation-messages.config';\r\nexport {NgxCustomMessageComponent} from './components/ngx-custom-message/ngx-custom-message.component';\r\nexport {NgxValidationMessagesComponent} from './components/ngx-validation-messages/ngx-validation-messages.component';\r\nexport {NgxValidatorNameDirective} from './directivies/ngx-validator-name.directive';\r\n\r\nexport function provideNgxValidationMessages(config: NgxValidationMessagesConfig): Provider[] {\r\n return [\r\n {\r\n provide: NGX_VALIDATION_MESSAGES_CONFIG,\r\n useValue: config\r\n }\r\n ];\r\n}\r\n","/*\n * Public API Surface of ngx-validation-messages\n */\nexport * from './lib/ngx-validation-messages.providers';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1.NgxValidationMessagesService"],"mappings":";;;;;;;MAEa,8BAA8B,GACvC,IAAI,cAAc,CAA8B,6BAA6B;;ACAjF;;;;;AAKG;MAYU,yBAAyB,CAAA;AAEpC;;AAEG;AAEI,IAAA,aAAa;AAEpB;;AAEG;AAEI,IAAA,OAAO;wGAZH,yBAAyB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAAzB,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,IAAA,EAAA,yBAAyB,EARxB,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,oBAAA,EAAA,MAAA,EAAA,EAAA,aAAA,EAAA,CAAA,cAAA,EAAA,eAAA,CAAA,EAAA,EAAA,WAAA,EAAA,CAAA,EAAA,YAAA,EAAA,SAAA,EAAA,KAAA,EAAA,IAAA,EAAA,SAAA,EAAA,CAAA,SAAA,CAAA,EAAA,WAAA,EAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,EAAA,EAAA,QAAA,EAAA;;;AAGH,UAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,YAAA,EAAA,CAAA,EAAA,IAAA,EAAA,UAAA,EAAA,IAAA,EAEH,YAAY,EAAA,CAAA,EAAA,CAAA;;4FAGP,yBAAyB,EAAA,UAAA,EAAA,CAAA;kBAXrC,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,UAAU,EAAE,IAAI;AAChB,oBAAA,QAAQ,EAAE,oBAAoB;AAC5B,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kB,EAAA,EAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EAAA,EAAA,CAAA,QAAA,EAAA,QAAA,EAAA,uBAAA,EAAA,MAAA,EAAA,CAAA,IAAA,CAAA,EAAA,CAAA,EAAA,CAAA;;4FAGb,8BAA8B,EAAA,UAAA,EAAA,CAAA;kBAV1C,SAAS;iCACI,IAAI,EAAA,QAAA,EACN,kDAAkD,EAGjD,OAAA,EAAA;wBACL,YAAY;wBACZ,kBAAkB;AACrB,qBAAA,EAAA,QAAA,EAAA,0sCAAA,EAAA,MAAA,EAAA,CAAA,0OAAA,CAAA,EAAA;;0BA+BU,MAAM;2BAAC,8BAA8B;0GAvB3C,WAAW,EAAA,CAAA;sBADjB,KAAK;uBAAC,KAAK;gBAOL,kBAAkB,EAAA,CAAA;sBADxB,eAAe;uBAAC,yBAAyB;gBAOnC,kBAAkB,EAAA,CAAA;sBADxB,eAAe;uBAAC,yBAAyB;;;AElCtC,SAAU,4BAA4B,CAAC,MAAmC,EAAA;IAC9E,OAAO;AACL,QAAA;AACE,YAAA,OAAO,EAAE,8BAA8B;AACvC,YAAA,QAAQ,EAAE;AACX;KACF;AACH;;ACfA;;AAEG;;ACFH;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"lagoshny-ngx-validation-messages.mjs","sources":["../../../projects/ngx-validation-messages/src/lib/interface/ngx-validation-messages.config.ts","../../../projects/ngx-validation-messages/src/lib/components/ngx-custom-message/ngx-custom-message.component.ts","../../../projects/ngx-validation-messages/src/lib/directivies/ngx-validator-name.directive.ts","../../../projects/ngx-validation-messages/src/lib/service/ngx-validation-messages.service.ts","../../../projects/ngx-validation-messages/src/lib/components/ngx-validation-messages/ngx-validation-messages.component.ts","../../../projects/ngx-validation-messages/src/lib/components/ngx-validation-messages/ngx-validation-messages.component.html","../../../projects/ngx-validation-messages/src/lib/ngx-validation-messages.providers.ts","../../../projects/ngx-validation-messages/src/public-api.ts","../../../projects/ngx-validation-messages/src/lagoshny-ngx-validation-messages.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\n\nexport const NGX_VALIDATION_MESSAGES_CONFIG: InjectionToken<NgxValidationMessagesConfig>\n = new InjectionToken<NgxValidationMessagesConfig>('NgxValidationMessagesConfig');\n\nexport interface NgxValidationMessagesConfig {\n\n /**\n * Object contains validation messages in validatorName: validatorMessage format.\n */\n messages: {\n [validatorName: string]: string;\n };\n\n /**\n * Define custom styles to display validation messages.\n */\n validationMessagesStyle?: {\n blockClassNames?: string;\n textClassNames?: string;\n };\n\n}\n","import { Component, ElementRef, Input, ViewChild } from '@angular/core';\n\n\n/**\n * Component allows specifying custom validation message for the specified\n * validator to override default message.\n *\n * Use this component as child in {@link NgxValidationMessagesComponent}.\n */\n@Component({\n standalone: true,\n selector: 'ngx-custom-message',\n template: `\n <div #message>\n <ng-content></ng-content>\n </div>`,\n imports: []\n})\nexport class NgxCustomMessageComponent {\n\n /**\n * The name of the validator for which you want to override the message.\n */\n @Input('forValidator')\n public validatorName: string;\n\n /**\n * Contains overridden message for validator.\n */\n @ViewChild('message')\n public message: ElementRef;\n\n}\n","import { AfterViewInit, Directive, ElementRef, Input } from '@angular/core';\n\n/**\n * Allows to specify custom validator message to override default message.\n *\n * It's alternative for {@link NgxCustomMessageComponent}.\n * If you want to use standard html tags to define custom message, use this directive on html tag within\n * {@link NgxValidationMessagesComponent} specifying validator name as directive parameter,\n * otherwise use {@link NgxCustomMessageComponent}.\n */\n@Directive({\n standalone: true,\n selector: '[ngxValidatorName]'\n})\nexport class NgxValidatorNameDirective implements AfterViewInit {\n\n /**\n * The name of the validator for which you want to override the message.\n */\n @Input()\n public validatorName: string;\n\n /**\n * Contains overridden message for validator.\n */\n public message: string;\n\n constructor(private elem: ElementRef) {\n }\n\n public ngAfterViewInit(): void {\n this.message = this.elem.nativeElement.innerText;\n }\n\n}\n","import { Inject, Injectable } from '@angular/core';\nimport { NGX_VALIDATION_MESSAGES_CONFIG, NgxValidationMessagesConfig } from '../interface/ngx-validation-messages.config';\n\n/**\n * Service allows getting validation messages from client's settings.\n * Injecting {@link NgxValidationMessagesConfig} to get client's configuration with validation messages.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class NgxValidationMessagesService {\n\n public static SERVER_ERRORS = 'serverErrors';\n\n /**\n * Regular expression to find params placeholder '#[paramName]'.\n */\n private paramsRegExp = new RegExp(/#[[a-zA-Z_\\\\-]*]/);\n\n constructor(@Inject(NGX_VALIDATION_MESSAGES_CONFIG) private messagesConfig: NgxValidationMessagesConfig) {\n }\n\n /**\n * Get validation message for specified validator.\n *\n * @param validatorName for which to get message\n * @param params passed from validator for more detailed validation message\n *\n * @returns string validation message\n */\n public getValidatorErrorMessages(validatorName: string, params?: object): string {\n const validationMessages = this.messagesConfig.messages;\n const validationMessage: string = validationMessages[validatorName];\n\n if (!validationMessage) {\n throw new Error('Validation message for validator: ' + validatorName\n + ' cannot be found, please check validation message key for validator it is case sensitive.');\n }\n\n if (params) {\n return this.expandParameterizedTemplateMessage(validationMessage, params);\n }\n\n return validationMessage;\n }\n\n public expandParameterizedTemplateMessage(msg: string, params: object): string {\n while (this.paramsRegExp.test(msg)) {\n const foundParams = this.paramsRegExp.exec(msg);\n foundParams.forEach(value => {\n const paramPlaceholder = value;\n value = value.replace('#[', '').replace(']', '');\n msg = msg.replace(paramPlaceholder, this.getParameter(params, value));\n });\n }\n\n return msg;\n }\n\n /**\n * A utilitarian method to get a property from an object.\n * if there is no property, an empty string is returned.\n *\n * @param obj from which the property must be obtained\n * @param prop property name\n *\n * @return property value or empty string\n */\n private getParameter(obj: object, prop: string): string {\n return prop.split('.')\n .reduce((m, i) => {\n return m && typeof m === 'object' ? m[i] : '';\n }, obj);\n }\n\n // public static applyServerError(control: AbstractControl | null, serverError: ServerError): void {\n // if (!control) {\n // return;\n // }\n // if (control.getError(NgxValidationMessagesService.SERVER_ERRORS)) {\n // const existingErrorMessages = control.getError(NgxValidationMessagesService.SERVER_ERRORS);\n // if (_.isArray(existingErrorMessages.customMessages) &&\n // existingErrorMessages.customMessages.indexOf(serverError.message) === -1) {\n // existingErrorMessages.customMessages.push(serverError.message);\n // }\n // } else {\n // control.setErrors({[NgxValidationMessagesService.SERVER_ERRORS]: {customMessages: [serverError.message]}});\n // }\n // control.markAsTouched();\n // }\n\n}\n","import { AfterViewInit, Component, ContentChildren, ElementRef, Inject, Input, QueryList } from '@angular/core';\nimport { NgxValidatorNameDirective } from '../../directivies/ngx-validator-name.directive';\nimport {\n NGX_VALIDATION_MESSAGES_CONFIG,\n NgxValidationMessagesConfig\n} from '../../interface/ngx-validation-messages.config';\nimport { NgxValidationMessagesService } from '../../service/ngx-validation-messages.service';\nimport { NgxCustomMessageComponent } from '../ngx-custom-message/ngx-custom-message.component';\nimport { CommonModule } from '@angular/common';\nimport { MatFormFieldModule } from '@angular/material/form-field';\n\n/**\n * Component for displaying validation messages, supports child components of type {@link NgxCustomMessageComponent}\n * and html elements with directive {@link NgxValidatorNameDirective} to override validation messages.\n */\n@Component({\n standalone: true,\n selector: 'ngx-validation-messages, [ngxValidationMessages]',\n templateUrl: './ngx-validation-messages.component.html',\n styleUrls: ['./ngx-validation-messages.component.scss'],\n imports: [\n CommonModule,\n MatFormFieldModule,\n ]\n})\nexport class NgxValidationMessagesComponent implements AfterViewInit {\n\n /**\n * Form control for which need to show validation messages.\n */\n @Input('for')\n public formControl: any;\n\n /**\n * Contains {@link NgxCustomMessageComponent} if present.\n */\n @ContentChildren(NgxCustomMessageComponent)\n public customMsgComponent: any;\n\n /**\n * Contains {@link NgxValidatorNameDirective} if present.\n */\n @ContentChildren(NgxValidatorNameDirective)\n public customMsgDirective: any;\n\n public isMaterialError = false;\n\n /**\n * Key to get default validation message.\n */\n private defaultError = 'error';\n\n private materialErrorElement = 'MAT-ERROR';\n\n constructor(@Inject(NGX_VALIDATION_MESSAGES_CONFIG) public ngxValidationConfig: NgxValidationMessagesConfig,\n private ngxValidationMessagesService: NgxValidationMessagesService,\n private directiveElementRef: ElementRef) {\n }\n\n public ngAfterViewInit(): void {\n if (this.directiveElementRef && this.directiveElementRef.nativeElement\n && this.directiveElementRef.nativeElement.nodeName) {\n this.isMaterialError = this.materialErrorElement.toLocaleUpperCase()\n === this.directiveElementRef.nativeElement.nodeName.toLocaleUpperCase();\n }\n }\n\n /**\n * Get all validation messages for specified form control.\n */\n public get errorMessages(): Array<string> {\n const result: Array<string> = [];\n\n if (!this.formControl || !this.formControl.errors) {\n return result;\n }\n if (this.customMsgComponent && this.customMsgComponent.length > 0) {\n this.processingCustomMessages(this.customMsgComponent);\n }\n if (this.customMsgDirective && this.customMsgDirective.length > 0) {\n this.processingCustomMessages(this.customMsgDirective);\n }\n\n for (const property in this.formControl.errors) {\n if (this.formControl.errors.hasOwnProperty(property)\n && (this.formControl.touched || this.formControl.dirty)) {\n if (this.formControl.errors[property].customMessages instanceof Array) {\n result.push(...this.formControl.errors[property].customMessages);\n continue;\n }\n if (this.formControl.errors[property].customMessage) {\n result.push(this.formControl.errors[property].customMessage);\n continue;\n }\n const validationMessage: string =\n this.ngxValidationMessagesService.getValidatorErrorMessages(property, this.formControl.errors[property]);\n result.push(validationMessage || this.formControl.errors[property].message\n || this.ngxValidationMessagesService.getValidatorErrorMessages(this.defaultError));\n }\n }\n return result;\n }\n\n private processingCustomMessages(customMessage: QueryList<any>): void {\n customMessage.forEach((msg: any) => {\n if (!this.formControl.errors[msg.validatorName]) {\n return;\n }\n let message = (msg instanceof NgxCustomMessageComponent)\n ? msg.message.nativeElement.innerText : msg.message;\n message = this.ngxValidationMessagesService.expandParameterizedTemplateMessage(message, this.formControl.errors[msg.validatorName]);\n\n typeof this.formControl.errors[msg.validatorName] === 'object'\n ? this.formControl.errors[msg.validatorName].customMessage = message\n : this.formControl.errors[msg.validatorName] = {customMessage: message};\n });\n }\n\n}\n","<!--To show error messages standalone without component-->\n@if (!formControl && customMsgComponent.length == 0 && customMsgDirective.length == 0) {\n <div\n [ngClass]=\"ngxValidationConfig?.validationMessagesStyle?.blockClassNames || 'ngx_vm__def_error_block'\">\n <span [ngClass]=\"ngxValidationConfig?.validationMessagesStyle?.textClassNames || 'ngx_vm__def_error_text'\">\n <ng-content></ng-content>\n </span>\n </div>\n}\n\n@if (errorMessages.length > 0) {\n <!--To show error messages in material ui style-->\n @if (isMaterialError) {\n @for (message of errorMessages; track message) {\n <mat-error>{{ message }}</mat-error>\n }\n } @else {\n <div [ngClass]=\"ngxValidationConfig?.validationMessagesStyle?.blockClassNames || 'ngx_vm__def_error_block'\">\n @for (message of errorMessages; track message) {\n <div>\n <span [ngClass]=\"ngxValidationConfig?.validationMessagesStyle?.textClassNames || 'ngx_vm__def_error_text'\">\n {{ message }}\n </span>\n </div>\n }\n </div>\n }\n <!--To show error messages in user style-->\n}\n","import { Provider } from '@angular/core';\r\nimport { NGX_VALIDATION_MESSAGES_CONFIG, NgxValidationMessagesConfig } from './interface/ngx-validation-messages.config';\r\n\r\nexport {NGX_VALIDATION_MESSAGES_CONFIG, NgxValidationMessagesConfig} from './interface/ngx-validation-messages.config';\r\nexport {NgxCustomMessageComponent} from './components/ngx-custom-message/ngx-custom-message.component';\r\nexport {NgxValidationMessagesComponent} from './components/ngx-validation-messages/ngx-validation-messages.component';\r\nexport {NgxValidatorNameDirective} from './directivies/ngx-validator-name.directive';\r\n\r\nexport function provideNgxValidationMessages(config: NgxValidationMessagesConfig): Provider[] {\r\n return [\r\n {\r\n provide: NGX_VALIDATION_MESSAGES_CONFIG,\r\n useValue: config\r\n }\r\n ];\r\n}\r\n","/*\n * Public API Surface of ngx-validation-messages\n */\nexport * from './lib/ngx-validation-messages.providers';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1.NgxValidationMessagesService"],"mappings":";;;;;;;MAEa,8BAA8B,GACvC,IAAI,cAAc,CAA8B,6BAA6B;;ACAjF;;;;;AAKG;MAUU,yBAAyB,CAAA;AAEpC;;AAEG;AAEI,IAAA,aAAa;AAEpB;;AAEG;AAEI,IAAA,OAAO;wGAZH,yBAAy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from '@angular/core';
|
|
3
|
+
|
|
4
|
+
declare const NGX_VALIDATION_MESSAGES_CONFIG: InjectionToken<NgxValidationMessagesConfig>;
|
|
5
|
+
interface NgxValidationMessagesConfig {
|
|
6
|
+
/**
|
|
7
|
+
* Object contains validation messages in validatorName: validatorMessage format.
|
|
8
|
+
*/
|
|
9
|
+
messages: {
|
|
10
|
+
[validatorName: string]: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Define custom styles to display validation messages.
|
|
14
|
+
*/
|
|
15
|
+
validationMessagesStyle?: {
|
|
16
|
+
blockClassNames?: string;
|
|
17
|
+
textClassNames?: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
1
21
|
/**
|
|
2
|
-
*
|
|
22
|
+
* Component allows specifying custom validation message for the specified
|
|
23
|
+
* validator to override default message.
|
|
24
|
+
*
|
|
25
|
+
* Use this component as child in {@link NgxValidationMessagesComponent}.
|
|
3
26
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
27
|
+
declare class NgxCustomMessageComponent {
|
|
28
|
+
/**
|
|
29
|
+
* The name of the validator for which you want to override the message.
|
|
30
|
+
*/
|
|
31
|
+
validatorName: string;
|
|
32
|
+
/**
|
|
33
|
+
* Contains overridden message for validator.
|
|
34
|
+
*/
|
|
35
|
+
message: ElementRef;
|
|
36
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NgxCustomMessageComponent, never>;
|
|
37
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<NgxCustomMessageComponent, "ngx-custom-message", never, { "validatorName": { "alias": "forValidator"; "required": false; }; }, {}, never, ["*"], true, never>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Service allows getting validation messages from client's settings.
|
|
42
|
+
* Injecting {@link NgxValidationMessagesConfig} to get client's configuration with validation messages.
|
|
43
|
+
*/
|
|
44
|
+
declare class NgxValidationMessagesService {
|
|
45
|
+
private messagesConfig;
|
|
46
|
+
static SERVER_ERRORS: string;
|
|
47
|
+
/**
|
|
48
|
+
* Regular expression to find params placeholder '#[paramName]'.
|
|
49
|
+
*/
|
|
50
|
+
private paramsRegExp;
|
|
51
|
+
constructor(messagesConfig: NgxValidationMessagesConfig);
|
|
52
|
+
/**
|
|
53
|
+
* Get validation message for specified validator.
|
|
54
|
+
*
|
|
55
|
+
* @param validatorName for which to get message
|
|
56
|
+
* @param params passed from validator for more detailed validation message
|
|
57
|
+
*
|
|
58
|
+
* @returns string validation message
|
|
59
|
+
*/
|
|
60
|
+
getValidatorErrorMessages(validatorName: string, params?: object): string;
|
|
61
|
+
expandParameterizedTemplateMessage(msg: string, params: object): string;
|
|
62
|
+
/**
|
|
63
|
+
* A utilitarian method to get a property from an object.
|
|
64
|
+
* if there is no property, an empty string is returned.
|
|
65
|
+
*
|
|
66
|
+
* @param obj from which the property must be obtained
|
|
67
|
+
* @param prop property name
|
|
68
|
+
*
|
|
69
|
+
* @return property value or empty string
|
|
70
|
+
*/
|
|
71
|
+
private getParameter;
|
|
72
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NgxValidationMessagesService, never>;
|
|
73
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<NgxValidationMessagesService>;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Component for displaying validation messages, supports child components of type {@link NgxCustomMessageComponent}
|
|
78
|
+
* and html elements with directive {@link NgxValidatorNameDirective} to override validation messages.
|
|
79
|
+
*/
|
|
80
|
+
declare class NgxValidationMessagesComponent implements AfterViewInit {
|
|
81
|
+
ngxValidationConfig: NgxValidationMessagesConfig;
|
|
82
|
+
private ngxValidationMessagesService;
|
|
83
|
+
private directiveElementRef;
|
|
84
|
+
/**
|
|
85
|
+
* Form control for which need to show validation messages.
|
|
86
|
+
*/
|
|
87
|
+
formControl: any;
|
|
88
|
+
/**
|
|
89
|
+
* Contains {@link NgxCustomMessageComponent} if present.
|
|
90
|
+
*/
|
|
91
|
+
customMsgComponent: any;
|
|
92
|
+
/**
|
|
93
|
+
* Contains {@link NgxValidatorNameDirective} if present.
|
|
94
|
+
*/
|
|
95
|
+
customMsgDirective: any;
|
|
96
|
+
isMaterialError: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Key to get default validation message.
|
|
99
|
+
*/
|
|
100
|
+
private defaultError;
|
|
101
|
+
private materialErrorElement;
|
|
102
|
+
constructor(ngxValidationConfig: NgxValidationMessagesConfig, ngxValidationMessagesService: NgxValidationMessagesService, directiveElementRef: ElementRef);
|
|
103
|
+
ngAfterViewInit(): void;
|
|
104
|
+
/**
|
|
105
|
+
* Get all validation messages for specified form control.
|
|
106
|
+
*/
|
|
107
|
+
get errorMessages(): Array<string>;
|
|
108
|
+
private processingCustomMessages;
|
|
109
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NgxValidationMessagesComponent, never>;
|
|
110
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<NgxValidationMessagesComponent, "ngx-validation-messages, [ngxValidationMessages]", never, { "formControl": { "alias": "for"; "required": false; }; }, {}, ["customMsgComponent", "customMsgDirective"], ["*"], true, never>;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Allows to specify custom validator message to override default message.
|
|
115
|
+
*
|
|
116
|
+
* It's alternative for {@link NgxCustomMessageComponent}.
|
|
117
|
+
* If you want to use standard html tags to define custom message, use this directive on html tag within
|
|
118
|
+
* {@link NgxValidationMessagesComponent} specifying validator name as directive parameter,
|
|
119
|
+
* otherwise use {@link NgxCustomMessageComponent}.
|
|
120
|
+
*/
|
|
121
|
+
declare class NgxValidatorNameDirective implements AfterViewInit {
|
|
122
|
+
private elem;
|
|
123
|
+
/**
|
|
124
|
+
* The name of the validator for which you want to override the message.
|
|
125
|
+
*/
|
|
126
|
+
validatorName: string;
|
|
127
|
+
/**
|
|
128
|
+
* Contains overridden message for validator.
|
|
129
|
+
*/
|
|
130
|
+
message: string;
|
|
131
|
+
constructor(elem: ElementRef);
|
|
132
|
+
ngAfterViewInit(): void;
|
|
133
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NgxValidatorNameDirective, never>;
|
|
134
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<NgxValidatorNameDirective, "[ngxValidatorName]", never, { "validatorName": { "alias": "validatorName"; "required": false; }; }, {}, never, never, true, never>;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
declare function provideNgxValidationMessages(config: NgxValidationMessagesConfig): Provider[];
|
|
138
|
+
|
|
139
|
+
export { NGX_VALIDATION_MESSAGES_CONFIG, NgxCustomMessageComponent, NgxValidationMessagesComponent, NgxValidatorNameDirective, provideNgxValidationMessages };
|
|
140
|
+
export type { NgxValidationMessagesConfig };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lagoshny/ngx-validation-messages",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "20.0.0",
|
|
4
4
|
"description": "This module allows to simplify display form validator validation messages using single component.",
|
|
5
5
|
"readme": "README.md",
|
|
6
6
|
"author": "Ilya Lagoshny <ilya@lagoshny.ru>",
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { ElementRef } from '@angular/core';
|
|
2
|
-
import * as i0 from "@angular/core";
|
|
3
|
-
/**
|
|
4
|
-
* Component allows specifying custom validation message for the specified
|
|
5
|
-
* validator to override default message.
|
|
6
|
-
*
|
|
7
|
-
* Use this component as child in {@link NgxValidationMessagesComponent}.
|
|
8
|
-
*/
|
|
9
|
-
export declare class NgxCustomMessageComponent {
|
|
10
|
-
/**
|
|
11
|
-
* The name of the validator for which you want to override the message.
|
|
12
|
-
*/
|
|
13
|
-
validatorName: string;
|
|
14
|
-
/**
|
|
15
|
-
* Contains overridden message for validator.
|
|
16
|
-
*/
|
|
17
|
-
message: ElementRef;
|
|
18
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<NgxCustomMessageComponent, never>;
|
|
19
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<NgxCustomMessageComponent, "ngx-custom-message", never, { "validatorName": { "alias": "forValidator"; "required": false; }; }, {}, never, ["*"], true, never>;
|
|
20
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { AfterViewInit, ElementRef } from '@angular/core';
|
|
2
|
-
import { NgxValidationMessagesConfig } from '../../interface/ngx-validation-messages.config';
|
|
3
|
-
import { NgxValidationMessagesService } from '../../service/ngx-validation-messages.service';
|
|
4
|
-
import * as i0 from "@angular/core";
|
|
5
|
-
/**
|
|
6
|
-
* Component for displaying validation messages, supports child components of type {@link NgxCustomMessageComponent}
|
|
7
|
-
* and html elements with directive {@link NgxValidatorNameDirective} to override validation messages.
|
|
8
|
-
*/
|
|
9
|
-
export declare class NgxValidationMessagesComponent implements AfterViewInit {
|
|
10
|
-
ngxValidationConfig: NgxValidationMessagesConfig;
|
|
11
|
-
private ngxValidationMessagesService;
|
|
12
|
-
private directiveElementRef;
|
|
13
|
-
/**
|
|
14
|
-
* Form control for which need to show validation messages.
|
|
15
|
-
*/
|
|
16
|
-
formControl: any;
|
|
17
|
-
/**
|
|
18
|
-
* Contains {@link NgxCustomMessageComponent} if present.
|
|
19
|
-
*/
|
|
20
|
-
customMsgComponent: any;
|
|
21
|
-
/**
|
|
22
|
-
* Contains {@link NgxValidatorNameDirective} if present.
|
|
23
|
-
*/
|
|
24
|
-
customMsgDirective: any;
|
|
25
|
-
isMaterialError: boolean;
|
|
26
|
-
/**
|
|
27
|
-
* Key to get default validation message.
|
|
28
|
-
*/
|
|
29
|
-
private defaultError;
|
|
30
|
-
private materialErrorElement;
|
|
31
|
-
constructor(ngxValidationConfig: NgxValidationMessagesConfig, ngxValidationMessagesService: NgxValidationMessagesService, directiveElementRef: ElementRef);
|
|
32
|
-
ngAfterViewInit(): void;
|
|
33
|
-
/**
|
|
34
|
-
* Get all validation messages for specified form control.
|
|
35
|
-
*/
|
|
36
|
-
get errorMessages(): Array<string>;
|
|
37
|
-
private processingCustomMessages;
|
|
38
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<NgxValidationMessagesComponent, never>;
|
|
39
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<NgxValidationMessagesComponent, "ngx-validation-messages, [ngxValidationMessages]", never, { "formControl": { "alias": "for"; "required": false; }; }, {}, ["customMsgComponent", "customMsgDirective"], ["*"], true, never>;
|
|
40
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { AfterViewInit, ElementRef } from '@angular/core';
|
|
2
|
-
import * as i0 from "@angular/core";
|
|
3
|
-
/**
|
|
4
|
-
* Allows to specify custom validator message to override default message.
|
|
5
|
-
*
|
|
6
|
-
* It's alternative for {@link NgxCustomMessageComponent}.
|
|
7
|
-
* If you want to use standard html tags to define custom message, use this directive on html tag within
|
|
8
|
-
* {@link NgxValidationMessagesComponent} specifying validator name as directive parameter,
|
|
9
|
-
* otherwise use {@link NgxCustomMessageComponent}.
|
|
10
|
-
*/
|
|
11
|
-
export declare class NgxValidatorNameDirective implements AfterViewInit {
|
|
12
|
-
private elem;
|
|
13
|
-
/**
|
|
14
|
-
* The name of the validator for which you want to override the message.
|
|
15
|
-
*/
|
|
16
|
-
validatorName: string;
|
|
17
|
-
/**
|
|
18
|
-
* Contains overridden message for validator.
|
|
19
|
-
*/
|
|
20
|
-
message: string;
|
|
21
|
-
constructor(elem: ElementRef);
|
|
22
|
-
ngAfterViewInit(): void;
|
|
23
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<NgxValidatorNameDirective, never>;
|
|
24
|
-
static ɵdir: i0.ɵɵDirectiveDeclaration<NgxValidatorNameDirective, "[ngxValidatorName]", never, { "validatorName": { "alias": "validatorName"; "required": false; }; }, {}, never, never, true, never>;
|
|
25
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { InjectionToken } from '@angular/core';
|
|
2
|
-
export declare const NGX_VALIDATION_MESSAGES_CONFIG: InjectionToken<NgxValidationMessagesConfig>;
|
|
3
|
-
export interface NgxValidationMessagesConfig {
|
|
4
|
-
/**
|
|
5
|
-
* Object contains validation messages in validatorName: validatorMessage format.
|
|
6
|
-
*/
|
|
7
|
-
messages: {
|
|
8
|
-
[validatorName: string]: string;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Define custom styles to display validation messages.
|
|
12
|
-
*/
|
|
13
|
-
validationMessagesStyle?: {
|
|
14
|
-
blockClassNames?: string;
|
|
15
|
-
textClassNames?: string;
|
|
16
|
-
};
|
|
17
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Provider } from '@angular/core';
|
|
2
|
-
import { NgxValidationMessagesConfig } from './interface/ngx-validation-messages.config';
|
|
3
|
-
export { NGX_VALIDATION_MESSAGES_CONFIG, NgxValidationMessagesConfig } from './interface/ngx-validation-messages.config';
|
|
4
|
-
export { NgxCustomMessageComponent } from './components/ngx-custom-message/ngx-custom-message.component';
|
|
5
|
-
export { NgxValidationMessagesComponent } from './components/ngx-validation-messages/ngx-validation-messages.component';
|
|
6
|
-
export { NgxValidatorNameDirective } from './directivies/ngx-validator-name.directive';
|
|
7
|
-
export declare function provideNgxValidationMessages(config: NgxValidationMessagesConfig): Provider[];
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { NgxValidationMessagesConfig } from '../interface/ngx-validation-messages.config';
|
|
2
|
-
import * as i0 from "@angular/core";
|
|
3
|
-
/**
|
|
4
|
-
* Service allows getting validation messages from client's settings.
|
|
5
|
-
* Injecting {@link NgxValidationMessagesConfig} to get client's configuration with validation messages.
|
|
6
|
-
*/
|
|
7
|
-
export declare class NgxValidationMessagesService {
|
|
8
|
-
private messagesConfig;
|
|
9
|
-
static SERVER_ERRORS: string;
|
|
10
|
-
/**
|
|
11
|
-
* Regular expression to find params placeholder '#[paramName]'.
|
|
12
|
-
*/
|
|
13
|
-
private paramsRegExp;
|
|
14
|
-
constructor(messagesConfig: NgxValidationMessagesConfig);
|
|
15
|
-
/**
|
|
16
|
-
* Get validation message for specified validator.
|
|
17
|
-
*
|
|
18
|
-
* @param validatorName for which to get message
|
|
19
|
-
* @param params passed from validator for more detailed validation message
|
|
20
|
-
*
|
|
21
|
-
* @returns string validation message
|
|
22
|
-
*/
|
|
23
|
-
getValidatorErrorMessages(validatorName: string, params?: object): string;
|
|
24
|
-
expandParameterizedTemplateMessage(msg: string, params: object): string;
|
|
25
|
-
/**
|
|
26
|
-
* A utilitarian method to get a property from an object.
|
|
27
|
-
* if there is no property, an empty string is returned.
|
|
28
|
-
*
|
|
29
|
-
* @param obj from which the property must be obtained
|
|
30
|
-
* @param prop property name
|
|
31
|
-
*
|
|
32
|
-
* @return property value or empty string
|
|
33
|
-
*/
|
|
34
|
-
private getParameter;
|
|
35
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<NgxValidationMessagesService, never>;
|
|
36
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<NgxValidationMessagesService>;
|
|
37
|
-
}
|
package/public-api.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './lib/ngx-validation-messages.providers';
|