@lagoshny/ngx-validation-messages 15.0.0 → 16.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/CHANGELOG.md +4 -0
- package/{esm2020 → esm2022}/lagoshny-ngx-validation-messages.mjs +4 -4
- package/esm2022/lib/components/ngx-custom-message/ngx-custom-message.component.mjs +40 -0
- package/esm2022/lib/components/ngx-validation-messages/ngx-validation-messages.component.mjs +112 -0
- package/esm2022/lib/directivies/ngx-validator-name.directive.mjs +38 -0
- package/{esm2020 → esm2022}/lib/interface/ngx-validation-messages.config.mjs +2 -2
- package/{esm2020 → esm2022}/lib/ngx-validation-messages.module.mjs +56 -56
- package/esm2022/lib/service/ngx-validation-messages.service.mjs +73 -0
- package/{esm2020 → esm2022}/public-api.mjs +4 -4
- package/{fesm2020 → fesm2022}/lagoshny-ngx-validation-messages.mjs +279 -246
- package/{fesm2015 → fesm2022}/lagoshny-ngx-validation-messages.mjs.map +1 -1
- package/index.d.ts +5 -5
- package/lib/components/ngx-custom-message/ngx-custom-message.component.d.ts +20 -20
- package/lib/components/ngx-validation-messages/ngx-validation-messages.component.d.ts +40 -40
- package/lib/directivies/ngx-validator-name.directive.d.ts +25 -25
- package/lib/interface/ngx-validation-messages.config.d.ts +17 -17
- package/lib/ngx-validation-messages.module.d.ts +18 -18
- package/lib/service/ngx-validation-messages.service.d.ts +37 -37
- package/package.json +5 -11
- package/public-api.d.ts +1 -1
- package/esm2020/lib/components/ngx-custom-message/ngx-custom-message.component.mjs +0 -32
- package/esm2020/lib/components/ngx-validation-messages/ngx-validation-messages.component.mjs +0 -97
- package/esm2020/lib/directivies/ngx-validator-name.directive.mjs +0 -29
- package/esm2020/lib/service/ngx-validation-messages.service.mjs +0 -72
- package/fesm2015/lagoshny-ngx-validation-messages.mjs +0 -280
- package/fesm2020/lagoshny-ngx-validation-messages.mjs.map +0 -1
|
@@ -5,271 +5,304 @@ import { Component, Input, ViewChild, Directive, InjectionToken, Injectable, Inj
|
|
|
5
5
|
import * as i3 from '@angular/material/form-field';
|
|
6
6
|
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
* Component allows specifying custom validation message for the specified
|
|
10
|
-
* validator to override default message.
|
|
11
|
-
*
|
|
12
|
-
* Use this component as child in {@link NgxValidationMessagesComponent}.
|
|
13
|
-
*/
|
|
14
|
-
class NgxCustomMessageComponent {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Component allows specifying custom validation message for the specified
|
|
10
|
+
* validator to override default message.
|
|
11
|
+
*
|
|
12
|
+
* Use this component as child in {@link NgxValidationMessagesComponent}.
|
|
13
|
+
*/
|
|
14
|
+
class NgxCustomMessageComponent {
|
|
15
|
+
/**
|
|
16
|
+
* The name of the validator for which you want to override the message.
|
|
17
|
+
*/
|
|
18
|
+
validatorName;
|
|
19
|
+
/**
|
|
20
|
+
* Contains overridden message for validator.
|
|
21
|
+
*/
|
|
22
|
+
message;
|
|
23
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NgxCustomMessageComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
24
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: NgxCustomMessageComponent, selector: "ngx-custom-message", inputs: { validatorName: ["forValidator", "validatorName"] }, viewQueries: [{ propertyName: "message", first: true, predicate: ["message"], descendants: true }], ngImport: i0, template: `
|
|
18
25
|
<div #message>
|
|
19
26
|
<ng-content></ng-content>
|
|
20
|
-
</div>`, isInline: true });
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
</div>`, isInline: true });
|
|
28
|
+
}
|
|
29
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NgxCustomMessageComponent, decorators: [{
|
|
30
|
+
type: Component,
|
|
31
|
+
args: [{
|
|
32
|
+
selector: 'ngx-custom-message',
|
|
25
33
|
template: `
|
|
26
34
|
<div #message>
|
|
27
35
|
<ng-content></ng-content>
|
|
28
|
-
</div>`
|
|
29
|
-
}]
|
|
30
|
-
}], propDecorators: { validatorName: [{
|
|
31
|
-
type: Input,
|
|
32
|
-
args: ['forValidator']
|
|
33
|
-
}], message: [{
|
|
34
|
-
type: ViewChild,
|
|
35
|
-
args: ['message']
|
|
36
|
+
</div>`
|
|
37
|
+
}]
|
|
38
|
+
}], propDecorators: { validatorName: [{
|
|
39
|
+
type: Input,
|
|
40
|
+
args: ['forValidator']
|
|
41
|
+
}], message: [{
|
|
42
|
+
type: ViewChild,
|
|
43
|
+
args: ['message']
|
|
36
44
|
}] } });
|
|
37
45
|
|
|
38
|
-
/**
|
|
39
|
-
* Allows to specify custom validator message to override default message.
|
|
40
|
-
*
|
|
41
|
-
* It's alternative for {@link NgxCustomMessageComponent}.
|
|
42
|
-
* If you want to use standard html tags to define custom message, use this directive on html tag within
|
|
43
|
-
* {@link NgxValidationMessagesComponent} specifying validator name as directive parameter,
|
|
44
|
-
* otherwise use {@link NgxCustomMessageComponent}.
|
|
45
|
-
*/
|
|
46
|
-
class NgxValidatorNameDirective {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Allows to specify custom validator message to override default message.
|
|
48
|
+
*
|
|
49
|
+
* It's alternative for {@link NgxCustomMessageComponent}.
|
|
50
|
+
* If you want to use standard html tags to define custom message, use this directive on html tag within
|
|
51
|
+
* {@link NgxValidationMessagesComponent} specifying validator name as directive parameter,
|
|
52
|
+
* otherwise use {@link NgxCustomMessageComponent}.
|
|
53
|
+
*/
|
|
54
|
+
class NgxValidatorNameDirective {
|
|
55
|
+
elem;
|
|
56
|
+
/**
|
|
57
|
+
* The name of the validator for which you want to override the message.
|
|
58
|
+
*/
|
|
59
|
+
validatorName;
|
|
60
|
+
/**
|
|
61
|
+
* Contains overridden message for validator.
|
|
62
|
+
*/
|
|
63
|
+
message;
|
|
64
|
+
constructor(elem) {
|
|
65
|
+
this.elem = elem;
|
|
66
|
+
}
|
|
67
|
+
ngAfterViewInit() {
|
|
68
|
+
this.message = this.elem.nativeElement.innerText;
|
|
69
|
+
}
|
|
70
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NgxValidatorNameDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
71
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: NgxValidatorNameDirective, selector: "[ngxValidatorName]", inputs: { validatorName: "validatorName" }, ngImport: i0 });
|
|
72
|
+
}
|
|
73
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NgxValidatorNameDirective, decorators: [{
|
|
74
|
+
type: Directive,
|
|
75
|
+
args: [{
|
|
76
|
+
selector: '[ngxValidatorName]'
|
|
77
|
+
}]
|
|
78
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { validatorName: [{
|
|
79
|
+
type: Input
|
|
63
80
|
}] } });
|
|
64
81
|
|
|
65
82
|
const NGX_VALIDATION_MESSAGES_CONFIG = new InjectionToken('NgxValidationMessagesConfig');
|
|
66
83
|
|
|
67
|
-
/**
|
|
68
|
-
* Service allows getting validation messages from client's settings.
|
|
69
|
-
* Injecting {@link NgxValidationMessagesConfig} to get client's configuration with validation messages.
|
|
70
|
-
*/
|
|
71
|
-
class NgxValidationMessagesService {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
* @
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
* @
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
84
|
+
/**
|
|
85
|
+
* Service allows getting validation messages from client's settings.
|
|
86
|
+
* Injecting {@link NgxValidationMessagesConfig} to get client's configuration with validation messages.
|
|
87
|
+
*/
|
|
88
|
+
class NgxValidationMessagesService {
|
|
89
|
+
messagesConfig;
|
|
90
|
+
static SERVER_ERRORS = 'serverErrors';
|
|
91
|
+
/**
|
|
92
|
+
* Regular expression to find params placeholder '#[paramName]'.
|
|
93
|
+
*/
|
|
94
|
+
paramsRegExp = new RegExp(/#[[a-zA-Z_\\-]*]/);
|
|
95
|
+
constructor(messagesConfig) {
|
|
96
|
+
this.messagesConfig = messagesConfig;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Get validation message for specified validator.
|
|
100
|
+
*
|
|
101
|
+
* @param validatorName for which to get message
|
|
102
|
+
* @param params passed from validator for more detailed validation message
|
|
103
|
+
*
|
|
104
|
+
* @returns string validation message
|
|
105
|
+
*/
|
|
106
|
+
getValidatorErrorMessages(validatorName, params) {
|
|
107
|
+
const validationMessages = this.messagesConfig.messages;
|
|
108
|
+
const validationMessage = validationMessages[validatorName];
|
|
109
|
+
if (!validationMessage) {
|
|
110
|
+
throw new Error('Validation message for validator: ' + validatorName
|
|
111
|
+
+ ' cannot be found, please check validation message key for validator it is case sensitive.');
|
|
112
|
+
}
|
|
113
|
+
if (params) {
|
|
114
|
+
return this.expandParameterizedTemplateMessage(validationMessage, params);
|
|
115
|
+
}
|
|
116
|
+
return validationMessage;
|
|
117
|
+
}
|
|
118
|
+
expandParameterizedTemplateMessage(msg, params) {
|
|
119
|
+
while (this.paramsRegExp.test(msg)) {
|
|
120
|
+
const foundParams = this.paramsRegExp.exec(msg);
|
|
121
|
+
foundParams.forEach(value => {
|
|
122
|
+
const paramPlaceholder = value;
|
|
123
|
+
value = value.replace('#[', '').replace(']', '');
|
|
124
|
+
msg = msg.replace(paramPlaceholder, this.getParameter(params, value));
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
return msg;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* A utilitarian method to get a property from an object.
|
|
131
|
+
* if there is no property, an empty string is returned.
|
|
132
|
+
*
|
|
133
|
+
* @param obj from which the property must be obtained
|
|
134
|
+
* @param prop property name
|
|
135
|
+
*
|
|
136
|
+
* @return property value or empty string
|
|
137
|
+
*/
|
|
138
|
+
getParameter(obj, prop) {
|
|
139
|
+
return prop.split('.')
|
|
140
|
+
.reduce((m, i) => {
|
|
141
|
+
return m && typeof m === 'object' ? m[i] : '';
|
|
142
|
+
}, obj);
|
|
143
|
+
}
|
|
144
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NgxValidationMessagesService, deps: [{ token: NGX_VALIDATION_MESSAGES_CONFIG }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
145
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NgxValidationMessagesService });
|
|
146
|
+
}
|
|
147
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NgxValidationMessagesService, decorators: [{
|
|
148
|
+
type: Injectable
|
|
149
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
150
|
+
type: Inject,
|
|
151
|
+
args: [NGX_VALIDATION_MESSAGES_CONFIG]
|
|
134
152
|
}] }]; } });
|
|
135
153
|
|
|
136
|
-
/**
|
|
137
|
-
* Component for displaying validation messages, supports child components of type {@link NgxCustomMessageComponent}
|
|
138
|
-
* and html elements with directive {@link NgxValidatorNameDirective} to override validation messages.
|
|
139
|
-
*/
|
|
140
|
-
class NgxValidationMessagesComponent {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
154
|
+
/**
|
|
155
|
+
* Component for displaying validation messages, supports child components of type {@link NgxCustomMessageComponent}
|
|
156
|
+
* and html elements with directive {@link NgxValidatorNameDirective} to override validation messages.
|
|
157
|
+
*/
|
|
158
|
+
class NgxValidationMessagesComponent {
|
|
159
|
+
ngxValidationConfig;
|
|
160
|
+
ngxValidationMessagesService;
|
|
161
|
+
directiveElementRef;
|
|
162
|
+
/**
|
|
163
|
+
* Form control for which need to show validation messages.
|
|
164
|
+
*/
|
|
165
|
+
formControl;
|
|
166
|
+
/**
|
|
167
|
+
* Contains {@link NgxCustomMessageComponent} if present.
|
|
168
|
+
*/
|
|
169
|
+
customMsgComponent;
|
|
170
|
+
/**
|
|
171
|
+
* Contains {@link NgxValidatorNameDirective} if present.
|
|
172
|
+
*/
|
|
173
|
+
customMsgDirective;
|
|
174
|
+
isMaterialError = false;
|
|
175
|
+
/**
|
|
176
|
+
* Key to get default validation message.
|
|
177
|
+
*/
|
|
178
|
+
defaultError = 'error';
|
|
179
|
+
materialErrorElement = 'MAT-ERROR';
|
|
180
|
+
constructor(ngxValidationConfig, ngxValidationMessagesService, directiveElementRef) {
|
|
181
|
+
this.ngxValidationConfig = ngxValidationConfig;
|
|
182
|
+
this.ngxValidationMessagesService = ngxValidationMessagesService;
|
|
183
|
+
this.directiveElementRef = directiveElementRef;
|
|
184
|
+
}
|
|
185
|
+
ngAfterViewInit() {
|
|
186
|
+
if (this.directiveElementRef && this.directiveElementRef.nativeElement
|
|
187
|
+
&& this.directiveElementRef.nativeElement.nodeName) {
|
|
188
|
+
this.isMaterialError = this.materialErrorElement.toLocaleUpperCase()
|
|
189
|
+
=== this.directiveElementRef.nativeElement.nodeName.toLocaleUpperCase();
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Get all validation messages for specified form control.
|
|
194
|
+
*/
|
|
195
|
+
get errorMessages() {
|
|
196
|
+
const result = [];
|
|
197
|
+
if (!this.formControl || !this.formControl.errors) {
|
|
198
|
+
return result;
|
|
199
|
+
}
|
|
200
|
+
if (this.customMsgComponent && this.customMsgComponent.length > 0) {
|
|
201
|
+
this.processingCustomMessages(this.customMsgComponent);
|
|
202
|
+
}
|
|
203
|
+
if (this.customMsgDirective && this.customMsgDirective.length > 0) {
|
|
204
|
+
this.processingCustomMessages(this.customMsgDirective);
|
|
205
|
+
}
|
|
206
|
+
for (const property in this.formControl.errors) {
|
|
207
|
+
if (this.formControl.errors.hasOwnProperty(property)
|
|
208
|
+
&& (this.formControl.touched || this.formControl.dirty)) {
|
|
209
|
+
if (this.formControl.errors[property].customMessages instanceof Array) {
|
|
210
|
+
result.push(...this.formControl.errors[property].customMessages);
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
if (this.formControl.errors[property].customMessage) {
|
|
214
|
+
result.push(this.formControl.errors[property].customMessage);
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
const validationMessage = this.ngxValidationMessagesService.getValidatorErrorMessages(property, this.formControl.errors[property]);
|
|
218
|
+
result.push(validationMessage || this.formControl.errors[property].message
|
|
219
|
+
|| this.ngxValidationMessagesService.getValidatorErrorMessages(this.defaultError));
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return result;
|
|
223
|
+
}
|
|
224
|
+
processingCustomMessages(customMessage) {
|
|
225
|
+
customMessage.forEach((msg) => {
|
|
226
|
+
if (!this.formControl.errors[msg.validatorName]) {
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
let message = (msg instanceof NgxCustomMessageComponent)
|
|
230
|
+
? msg.message.nativeElement.innerText : msg.message;
|
|
231
|
+
message = this.ngxValidationMessagesService.expandParameterizedTemplateMessage(message, this.formControl.errors[msg.validatorName]);
|
|
232
|
+
typeof this.formControl.errors[msg.validatorName] === 'object'
|
|
233
|
+
? this.formControl.errors[msg.validatorName].customMessage = message
|
|
234
|
+
: this.formControl.errors[msg.validatorName] = { customMessage: message };
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NgxValidationMessagesComponent, deps: [{ token: NGX_VALIDATION_MESSAGES_CONFIG }, { token: NgxValidationMessagesService }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
238
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: NgxValidationMessagesComponent, 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<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", 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: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i3.MatError, selector: "mat-error, [matError]", inputs: ["id"] }] });
|
|
239
|
+
}
|
|
240
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NgxValidationMessagesComponent, decorators: [{
|
|
241
|
+
type: Component,
|
|
242
|
+
args: [{ selector: 'ngx-validation-messages, [ngxValidationMessages]', template: "<!--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", 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"] }]
|
|
243
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
244
|
+
type: Inject,
|
|
245
|
+
args: [NGX_VALIDATION_MESSAGES_CONFIG]
|
|
246
|
+
}] }, { type: NgxValidationMessagesService }, { type: i0.ElementRef }]; }, propDecorators: { formControl: [{
|
|
247
|
+
type: Input,
|
|
248
|
+
args: ['for']
|
|
249
|
+
}], customMsgComponent: [{
|
|
250
|
+
type: ContentChildren,
|
|
251
|
+
args: [NgxCustomMessageComponent]
|
|
252
|
+
}], customMsgDirective: [{
|
|
253
|
+
type: ContentChildren,
|
|
254
|
+
args: [NgxValidatorNameDirective]
|
|
222
255
|
}] } });
|
|
223
256
|
|
|
224
|
-
class NgxValidationMessagesModule {
|
|
225
|
-
static forRoot(config) {
|
|
226
|
-
return {
|
|
227
|
-
ngModule: NgxValidationMessagesModule,
|
|
228
|
-
providers: [
|
|
229
|
-
NgxValidationMessagesService,
|
|
230
|
-
{
|
|
231
|
-
provide: NGX_VALIDATION_MESSAGES_CONFIG,
|
|
232
|
-
useValue: config
|
|
233
|
-
}
|
|
234
|
-
]
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
248
|
-
type: NgModule,
|
|
249
|
-
args: [{
|
|
250
|
-
imports: [
|
|
251
|
-
CommonModule,
|
|
252
|
-
MatFormFieldModule,
|
|
253
|
-
],
|
|
254
|
-
declarations: [
|
|
255
|
-
NgxValidationMessagesComponent,
|
|
256
|
-
NgxCustomMessageComponent,
|
|
257
|
-
NgxValidatorNameDirective
|
|
258
|
-
],
|
|
259
|
-
exports: [
|
|
260
|
-
NgxValidationMessagesComponent,
|
|
261
|
-
NgxCustomMessageComponent,
|
|
262
|
-
NgxValidatorNameDirective
|
|
263
|
-
]
|
|
264
|
-
}]
|
|
257
|
+
class NgxValidationMessagesModule {
|
|
258
|
+
static forRoot(config) {
|
|
259
|
+
return {
|
|
260
|
+
ngModule: NgxValidationMessagesModule,
|
|
261
|
+
providers: [
|
|
262
|
+
NgxValidationMessagesService,
|
|
263
|
+
{
|
|
264
|
+
provide: NGX_VALIDATION_MESSAGES_CONFIG,
|
|
265
|
+
useValue: config
|
|
266
|
+
}
|
|
267
|
+
]
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NgxValidationMessagesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
271
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: NgxValidationMessagesModule, declarations: [NgxValidationMessagesComponent,
|
|
272
|
+
NgxCustomMessageComponent,
|
|
273
|
+
NgxValidatorNameDirective], imports: [CommonModule,
|
|
274
|
+
MatFormFieldModule], exports: [NgxValidationMessagesComponent,
|
|
275
|
+
NgxCustomMessageComponent,
|
|
276
|
+
NgxValidatorNameDirective] });
|
|
277
|
+
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NgxValidationMessagesModule, imports: [CommonModule,
|
|
278
|
+
MatFormFieldModule] });
|
|
279
|
+
}
|
|
280
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NgxValidationMessagesModule, decorators: [{
|
|
281
|
+
type: NgModule,
|
|
282
|
+
args: [{
|
|
283
|
+
imports: [
|
|
284
|
+
CommonModule,
|
|
285
|
+
MatFormFieldModule,
|
|
286
|
+
],
|
|
287
|
+
declarations: [
|
|
288
|
+
NgxValidationMessagesComponent,
|
|
289
|
+
NgxCustomMessageComponent,
|
|
290
|
+
NgxValidatorNameDirective
|
|
291
|
+
],
|
|
292
|
+
exports: [
|
|
293
|
+
NgxValidationMessagesComponent,
|
|
294
|
+
NgxCustomMessageComponent,
|
|
295
|
+
NgxValidatorNameDirective
|
|
296
|
+
]
|
|
297
|
+
}]
|
|
265
298
|
}] });
|
|
266
299
|
|
|
267
|
-
/*
|
|
268
|
-
* Public API Surface of ngx-validation-messages
|
|
300
|
+
/*
|
|
301
|
+
* Public API Surface of ngx-validation-messages
|
|
269
302
|
*/
|
|
270
303
|
|
|
271
|
-
/**
|
|
272
|
-
* Generated bundle index. Do not edit.
|
|
304
|
+
/**
|
|
305
|
+
* Generated bundle index. Do not edit.
|
|
273
306
|
*/
|
|
274
307
|
|
|
275
308
|
export { NGX_VALIDATION_MESSAGES_CONFIG, NgxCustomMessageComponent, NgxValidationMessagesComponent, NgxValidationMessagesModule, NgxValidatorNameDirective };
|