@lagoshny/ngx-validation-messages 2.0.2 → 15.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.
Files changed (34) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/README.md +427 -425
  3. package/esm2020/lagoshny-ngx-validation-messages.mjs +5 -0
  4. package/esm2020/lib/components/ngx-custom-message/ngx-custom-message.component.mjs +32 -0
  5. package/esm2020/lib/components/ngx-validation-messages/ngx-validation-messages.component.mjs +97 -0
  6. package/esm2020/lib/directivies/ngx-validator-name.directive.mjs +29 -0
  7. package/esm2020/lib/interface/ngx-validation-messages.config.mjs +3 -0
  8. package/esm2020/lib/ngx-validation-messages.module.mjs +56 -0
  9. package/esm2020/lib/service/ngx-validation-messages.service.mjs +72 -0
  10. package/{esm2015/public-api.js → esm2020/public-api.mjs} +1 -1
  11. package/fesm2015/lagoshny-ngx-validation-messages.mjs +280 -0
  12. package/fesm2015/lagoshny-ngx-validation-messages.mjs.map +1 -0
  13. package/fesm2020/lagoshny-ngx-validation-messages.mjs +276 -0
  14. package/fesm2020/lagoshny-ngx-validation-messages.mjs.map +1 -0
  15. package/index.d.ts +5 -0
  16. package/lib/components/ngx-custom-message/ngx-custom-message.component.d.ts +3 -0
  17. package/lib/components/ngx-validation-messages/ngx-validation-messages.component.d.ts +3 -0
  18. package/lib/directivies/ngx-validator-name.directive.d.ts +3 -0
  19. package/lib/ngx-validation-messages.module.d.ts +9 -0
  20. package/lib/service/ngx-validation-messages.service.d.ts +3 -0
  21. package/package.json +24 -16
  22. package/bundles/lagoshny-ngx-validation-messages.umd.js +0 -594
  23. package/bundles/lagoshny-ngx-validation-messages.umd.js.map +0 -1
  24. package/esm2015/lagoshny-ngx-validation-messages.js +0 -6
  25. package/esm2015/lib/components/ngx-custom-message/ngx-custom-message.component.js +0 -23
  26. package/esm2015/lib/components/ngx-validation-messages/ngx-validation-messages.component.js +0 -92
  27. package/esm2015/lib/directivies/ngx-validator-name.directive.js +0 -29
  28. package/esm2015/lib/interface/ngx-validation-messages.config.js +0 -3
  29. package/esm2015/lib/ngx-validation-messages.module.js +0 -45
  30. package/esm2015/lib/service/ngx-validation-messages.service.js +0 -69
  31. package/fesm2015/lagoshny-ngx-validation-messages.js +0 -253
  32. package/fesm2015/lagoshny-ngx-validation-messages.js.map +0 -1
  33. package/lagoshny-ngx-validation-messages.d.ts +0 -5
  34. package/lagoshny-ngx-validation-messages.metadata.json +0 -1
@@ -1,594 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common'), require('@angular/core'), require('@angular/material/form-field')) :
3
- typeof define === 'function' && define.amd ? define('@lagoshny/ngx-validation-messages', ['exports', '@angular/common', '@angular/core', '@angular/material/form-field'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.lagoshny = global.lagoshny || {}, global.lagoshny["ngx-validation-messages"] = {}), global.ng.common, global.ng.core, global.ng.material.formField));
5
- })(this, (function (exports, common, core, formField) { 'use strict';
6
-
7
- /**
8
- * Component allows specifying custom validation message for the specified
9
- * validator to override default message.
10
- *
11
- * Use this component as child in {@link NgxValidationMessagesComponent}.
12
- */
13
- var NgxCustomMessageComponent = /** @class */ (function () {
14
- function NgxCustomMessageComponent() {
15
- }
16
- return NgxCustomMessageComponent;
17
- }());
18
- NgxCustomMessageComponent.decorators = [
19
- { type: core.Component, args: [{
20
- selector: 'ngx-custom-message',
21
- template: "\n <div #message>\n <ng-content></ng-content>\n </div>"
22
- },] }
23
- ];
24
- NgxCustomMessageComponent.propDecorators = {
25
- validatorName: [{ type: core.Input, args: ['forValidator',] }],
26
- message: [{ type: core.ViewChild, args: ['message',] }]
27
- };
28
-
29
- /*! *****************************************************************************
30
- Copyright (c) Microsoft Corporation.
31
-
32
- Permission to use, copy, modify, and/or distribute this software for any
33
- purpose with or without fee is hereby granted.
34
-
35
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
36
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
37
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
38
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
39
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
40
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
41
- PERFORMANCE OF THIS SOFTWARE.
42
- ***************************************************************************** */
43
- /* global Reflect, Promise */
44
- var extendStatics = function (d, b) {
45
- extendStatics = Object.setPrototypeOf ||
46
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
47
- function (d, b) { for (var p in b)
48
- if (Object.prototype.hasOwnProperty.call(b, p))
49
- d[p] = b[p]; };
50
- return extendStatics(d, b);
51
- };
52
- function __extends(d, b) {
53
- if (typeof b !== "function" && b !== null)
54
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
55
- extendStatics(d, b);
56
- function __() { this.constructor = d; }
57
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
58
- }
59
- var __assign = function () {
60
- __assign = Object.assign || function __assign(t) {
61
- for (var s, i = 1, n = arguments.length; i < n; i++) {
62
- s = arguments[i];
63
- for (var p in s)
64
- if (Object.prototype.hasOwnProperty.call(s, p))
65
- t[p] = s[p];
66
- }
67
- return t;
68
- };
69
- return __assign.apply(this, arguments);
70
- };
71
- function __rest(s, e) {
72
- var t = {};
73
- for (var p in s)
74
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
75
- t[p] = s[p];
76
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
77
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
78
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
79
- t[p[i]] = s[p[i]];
80
- }
81
- return t;
82
- }
83
- function __decorate(decorators, target, key, desc) {
84
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
85
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
86
- r = Reflect.decorate(decorators, target, key, desc);
87
- else
88
- for (var i = decorators.length - 1; i >= 0; i--)
89
- if (d = decorators[i])
90
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
91
- return c > 3 && r && Object.defineProperty(target, key, r), r;
92
- }
93
- function __param(paramIndex, decorator) {
94
- return function (target, key) { decorator(target, key, paramIndex); };
95
- }
96
- function __metadata(metadataKey, metadataValue) {
97
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
98
- return Reflect.metadata(metadataKey, metadataValue);
99
- }
100
- function __awaiter(thisArg, _arguments, P, generator) {
101
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
102
- return new (P || (P = Promise))(function (resolve, reject) {
103
- function fulfilled(value) { try {
104
- step(generator.next(value));
105
- }
106
- catch (e) {
107
- reject(e);
108
- } }
109
- function rejected(value) { try {
110
- step(generator["throw"](value));
111
- }
112
- catch (e) {
113
- reject(e);
114
- } }
115
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
116
- step((generator = generator.apply(thisArg, _arguments || [])).next());
117
- });
118
- }
119
- function __generator(thisArg, body) {
120
- var _ = { label: 0, sent: function () { if (t[0] & 1)
121
- throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
122
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
123
- function verb(n) { return function (v) { return step([n, v]); }; }
124
- function step(op) {
125
- if (f)
126
- throw new TypeError("Generator is already executing.");
127
- while (_)
128
- try {
129
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
130
- return t;
131
- if (y = 0, t)
132
- op = [op[0] & 2, t.value];
133
- switch (op[0]) {
134
- case 0:
135
- case 1:
136
- t = op;
137
- break;
138
- case 4:
139
- _.label++;
140
- return { value: op[1], done: false };
141
- case 5:
142
- _.label++;
143
- y = op[1];
144
- op = [0];
145
- continue;
146
- case 7:
147
- op = _.ops.pop();
148
- _.trys.pop();
149
- continue;
150
- default:
151
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
152
- _ = 0;
153
- continue;
154
- }
155
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
156
- _.label = op[1];
157
- break;
158
- }
159
- if (op[0] === 6 && _.label < t[1]) {
160
- _.label = t[1];
161
- t = op;
162
- break;
163
- }
164
- if (t && _.label < t[2]) {
165
- _.label = t[2];
166
- _.ops.push(op);
167
- break;
168
- }
169
- if (t[2])
170
- _.ops.pop();
171
- _.trys.pop();
172
- continue;
173
- }
174
- op = body.call(thisArg, _);
175
- }
176
- catch (e) {
177
- op = [6, e];
178
- y = 0;
179
- }
180
- finally {
181
- f = t = 0;
182
- }
183
- if (op[0] & 5)
184
- throw op[1];
185
- return { value: op[0] ? op[1] : void 0, done: true };
186
- }
187
- }
188
- var __createBinding = Object.create ? (function (o, m, k, k2) {
189
- if (k2 === undefined)
190
- k2 = k;
191
- Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
192
- }) : (function (o, m, k, k2) {
193
- if (k2 === undefined)
194
- k2 = k;
195
- o[k2] = m[k];
196
- });
197
- function __exportStar(m, o) {
198
- for (var p in m)
199
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
200
- __createBinding(o, m, p);
201
- }
202
- function __values(o) {
203
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
204
- if (m)
205
- return m.call(o);
206
- if (o && typeof o.length === "number")
207
- return {
208
- next: function () {
209
- if (o && i >= o.length)
210
- o = void 0;
211
- return { value: o && o[i++], done: !o };
212
- }
213
- };
214
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
215
- }
216
- function __read(o, n) {
217
- var m = typeof Symbol === "function" && o[Symbol.iterator];
218
- if (!m)
219
- return o;
220
- var i = m.call(o), r, ar = [], e;
221
- try {
222
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
223
- ar.push(r.value);
224
- }
225
- catch (error) {
226
- e = { error: error };
227
- }
228
- finally {
229
- try {
230
- if (r && !r.done && (m = i["return"]))
231
- m.call(i);
232
- }
233
- finally {
234
- if (e)
235
- throw e.error;
236
- }
237
- }
238
- return ar;
239
- }
240
- /** @deprecated */
241
- function __spread() {
242
- for (var ar = [], i = 0; i < arguments.length; i++)
243
- ar = ar.concat(__read(arguments[i]));
244
- return ar;
245
- }
246
- /** @deprecated */
247
- function __spreadArrays() {
248
- for (var s = 0, i = 0, il = arguments.length; i < il; i++)
249
- s += arguments[i].length;
250
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
251
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
252
- r[k] = a[j];
253
- return r;
254
- }
255
- function __spreadArray(to, from, pack) {
256
- if (pack || arguments.length === 2)
257
- for (var i = 0, l = from.length, ar; i < l; i++) {
258
- if (ar || !(i in from)) {
259
- if (!ar)
260
- ar = Array.prototype.slice.call(from, 0, i);
261
- ar[i] = from[i];
262
- }
263
- }
264
- return to.concat(ar || Array.prototype.slice.call(from));
265
- }
266
- function __await(v) {
267
- return this instanceof __await ? (this.v = v, this) : new __await(v);
268
- }
269
- function __asyncGenerator(thisArg, _arguments, generator) {
270
- if (!Symbol.asyncIterator)
271
- throw new TypeError("Symbol.asyncIterator is not defined.");
272
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
273
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
274
- function verb(n) { if (g[n])
275
- i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
276
- function resume(n, v) { try {
277
- step(g[n](v));
278
- }
279
- catch (e) {
280
- settle(q[0][3], e);
281
- } }
282
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
283
- function fulfill(value) { resume("next", value); }
284
- function reject(value) { resume("throw", value); }
285
- function settle(f, v) { if (f(v), q.shift(), q.length)
286
- resume(q[0][0], q[0][1]); }
287
- }
288
- function __asyncDelegator(o) {
289
- var i, p;
290
- return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
291
- function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
292
- }
293
- function __asyncValues(o) {
294
- if (!Symbol.asyncIterator)
295
- throw new TypeError("Symbol.asyncIterator is not defined.");
296
- var m = o[Symbol.asyncIterator], i;
297
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
298
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
299
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
300
- }
301
- function __makeTemplateObject(cooked, raw) {
302
- if (Object.defineProperty) {
303
- Object.defineProperty(cooked, "raw", { value: raw });
304
- }
305
- else {
306
- cooked.raw = raw;
307
- }
308
- return cooked;
309
- }
310
- ;
311
- var __setModuleDefault = Object.create ? (function (o, v) {
312
- Object.defineProperty(o, "default", { enumerable: true, value: v });
313
- }) : function (o, v) {
314
- o["default"] = v;
315
- };
316
- function __importStar(mod) {
317
- if (mod && mod.__esModule)
318
- return mod;
319
- var result = {};
320
- if (mod != null)
321
- for (var k in mod)
322
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
323
- __createBinding(result, mod, k);
324
- __setModuleDefault(result, mod);
325
- return result;
326
- }
327
- function __importDefault(mod) {
328
- return (mod && mod.__esModule) ? mod : { default: mod };
329
- }
330
- function __classPrivateFieldGet(receiver, state, kind, f) {
331
- if (kind === "a" && !f)
332
- throw new TypeError("Private accessor was defined without a getter");
333
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
334
- throw new TypeError("Cannot read private member from an object whose class did not declare it");
335
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
336
- }
337
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
338
- if (kind === "m")
339
- throw new TypeError("Private method is not writable");
340
- if (kind === "a" && !f)
341
- throw new TypeError("Private accessor was defined without a setter");
342
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
343
- throw new TypeError("Cannot write private member to an object whose class did not declare it");
344
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
345
- }
346
-
347
- /**
348
- * Allows to specify custom validator message to override default message.
349
- *
350
- * It's alternative for {@link NgxCustomMessageComponent}.
351
- * If you want to use standard html tags to define custom message, use this directive on html tag within
352
- * {@link NgxValidationMessagesComponent} specifying validator name as directive parameter,
353
- * otherwise use {@link NgxCustomMessageComponent}.
354
- */
355
- var NgxValidatorNameDirective = /** @class */ (function () {
356
- function NgxValidatorNameDirective(elem) {
357
- this.elem = elem;
358
- }
359
- NgxValidatorNameDirective.prototype.ngAfterViewInit = function () {
360
- this.message = this.elem.nativeElement.innerText;
361
- };
362
- return NgxValidatorNameDirective;
363
- }());
364
- NgxValidatorNameDirective.decorators = [
365
- { type: core.Directive, args: [{
366
- selector: '[ngxValidatorName]'
367
- },] }
368
- ];
369
- NgxValidatorNameDirective.ctorParameters = function () { return [
370
- { type: core.ElementRef }
371
- ]; };
372
- NgxValidatorNameDirective.propDecorators = {
373
- validatorName: [{ type: core.Input }]
374
- };
375
-
376
- var NGX_VALIDATION_MESSAGES_CONFIG = new core.InjectionToken('NgxValidationMessagesConfig');
377
-
378
- /**
379
- * Service allows getting validation messages from client's settings.
380
- * Injecting {@link NgxValidationMessagesConfig} to get client's configuration with validation messages.
381
- */
382
- var NgxValidationMessagesService = /** @class */ (function () {
383
- function NgxValidationMessagesService(messagesConfig) {
384
- this.messagesConfig = messagesConfig;
385
- /**
386
- * Regular expression to find params placeholder '#[paramName]'.
387
- */
388
- this.paramsRegExp = new RegExp(/#[[a-zA-Z_\\-]*]/);
389
- }
390
- /**
391
- * Get validation message for specified validator.
392
- *
393
- * @param validatorName for which to get message
394
- * @param params passed from validator for more detailed validation message
395
- *
396
- * @returns string validation message
397
- */
398
- NgxValidationMessagesService.prototype.getValidatorErrorMessages = function (validatorName, params) {
399
- var validationMessages = this.messagesConfig.messages;
400
- var validationMessage = validationMessages[validatorName];
401
- if (!validationMessage) {
402
- throw new Error('Validation message for validator: ' + validatorName
403
- + ' cannot be found, please check validation message key for validator it is case sensitive.');
404
- }
405
- if (params) {
406
- return this.expandParameterizedTemplateMessage(validationMessage, params);
407
- }
408
- return validationMessage;
409
- };
410
- NgxValidationMessagesService.prototype.expandParameterizedTemplateMessage = function (msg, params) {
411
- var _this = this;
412
- while (this.paramsRegExp.test(msg)) {
413
- var foundParams = this.paramsRegExp.exec(msg);
414
- foundParams.forEach(function (value) {
415
- var paramPlaceholder = value;
416
- value = value.replace('#[', '').replace(']', '');
417
- msg = msg.replace(paramPlaceholder, _this.getParameter(params, value));
418
- });
419
- }
420
- return msg;
421
- };
422
- /**
423
- * A utilitarian method to get a property from an object.
424
- * if there is no property, an empty string is returned.
425
- *
426
- * @param obj from which the property must be obtained
427
- * @param prop property name
428
- *
429
- * @return property value or empty string
430
- */
431
- NgxValidationMessagesService.prototype.getParameter = function (obj, prop) {
432
- return prop.split('.')
433
- .reduce(function (m, i) {
434
- return m && typeof m === 'object' ? m[i] : '';
435
- }, obj);
436
- };
437
- return NgxValidationMessagesService;
438
- }());
439
- NgxValidationMessagesService.SERVER_ERRORS = 'serverErrors';
440
- NgxValidationMessagesService.decorators = [
441
- { type: core.Injectable }
442
- ];
443
- NgxValidationMessagesService.ctorParameters = function () { return [
444
- { type: undefined, decorators: [{ type: core.Inject, args: [NGX_VALIDATION_MESSAGES_CONFIG,] }] }
445
- ]; };
446
-
447
- /**
448
- * Component for displaying validation messages, supports child components of type {@link NgxCustomMessageComponent}
449
- * and html elements with directive {@link NgxValidatorNameDirective} to override validation messages.
450
- */
451
- var NgxValidationMessagesComponent = /** @class */ (function () {
452
- function NgxValidationMessagesComponent(ngxValidationConfig, ngxValidationMessagesService, directiveElementRef) {
453
- this.ngxValidationConfig = ngxValidationConfig;
454
- this.ngxValidationMessagesService = ngxValidationMessagesService;
455
- this.directiveElementRef = directiveElementRef;
456
- this.isMaterialError = false;
457
- /**
458
- * Key to get default validation message.
459
- */
460
- this.defaultError = 'error';
461
- this.materialErrorElement = 'MAT-ERROR';
462
- }
463
- NgxValidationMessagesComponent.prototype.ngAfterViewInit = function () {
464
- if (this.directiveElementRef && this.directiveElementRef.nativeElement
465
- && this.directiveElementRef.nativeElement.nodeName) {
466
- this.isMaterialError = this.materialErrorElement.toLocaleUpperCase()
467
- === this.directiveElementRef.nativeElement.nodeName.toLocaleUpperCase();
468
- }
469
- };
470
- Object.defineProperty(NgxValidationMessagesComponent.prototype, "errorMessages", {
471
- /**
472
- * Get all validation messages for specified form control.
473
- */
474
- get: function () {
475
- var result = [];
476
- if (!this.formControl || !this.formControl.errors) {
477
- return result;
478
- }
479
- if (this.customMsgComponent && this.customMsgComponent.length > 0) {
480
- this.processingCustomMessages(this.customMsgComponent);
481
- }
482
- if (this.customMsgDirective && this.customMsgDirective.length > 0) {
483
- this.processingCustomMessages(this.customMsgDirective);
484
- }
485
- for (var property in this.formControl.errors) {
486
- if (this.formControl.errors.hasOwnProperty(property)
487
- && (this.formControl.touched || this.formControl.dirty)) {
488
- if (this.formControl.errors[property].customMessages instanceof Array) {
489
- result.push.apply(result, __spreadArray([], __read(this.formControl.errors[property].customMessages)));
490
- continue;
491
- }
492
- if (this.formControl.errors[property].customMessage) {
493
- result.push(this.formControl.errors[property].customMessage);
494
- continue;
495
- }
496
- var validationMessage = this.ngxValidationMessagesService.getValidatorErrorMessages(property, this.formControl.errors[property]);
497
- result.push(validationMessage || this.formControl.errors[property].message
498
- || this.ngxValidationMessagesService.getValidatorErrorMessages(this.defaultError));
499
- }
500
- }
501
- return result;
502
- },
503
- enumerable: false,
504
- configurable: true
505
- });
506
- NgxValidationMessagesComponent.prototype.processingCustomMessages = function (customMessage) {
507
- var _this = this;
508
- customMessage.forEach(function (msg) {
509
- if (!_this.formControl.errors[msg.validatorName]) {
510
- return;
511
- }
512
- var message = (msg instanceof NgxCustomMessageComponent)
513
- ? msg.message.nativeElement.innerText : msg.message;
514
- message = _this.ngxValidationMessagesService.expandParameterizedTemplateMessage(message, _this.formControl.errors[msg.validatorName]);
515
- typeof _this.formControl.errors[msg.validatorName] === 'object'
516
- ? _this.formControl.errors[msg.validatorName].customMessage = message
517
- : _this.formControl.errors[msg.validatorName] = { customMessage: message };
518
- });
519
- };
520
- return NgxValidationMessagesComponent;
521
- }());
522
- NgxValidationMessagesComponent.decorators = [
523
- { type: core.Component, args: [{
524
- selector: 'ngx-validation-messages, [ngxValidationMessages]',
525
- template: "<!--To show error messages standalone without component-->\r\n<div *ngIf=\"!formControl && customMsgComponent.length == 0 && customMsgDirective.length == 0\"\r\n [ngClass]=\"ngxValidationConfig?.validationMessagesStyle?.blockClassNames || 'ngx_vm__def_error_block'\">\r\n <span [ngClass]=\"ngxValidationConfig?.validationMessagesStyle?.textClassNames || 'ngx_vm__def_error_text'\">\r\n <ng-content></ng-content>\r\n </span>\r\n</div>\r\n\r\n<ng-container *ngIf=\"errorMessages.length > 0\">\r\n\r\n <!--To show error messages in material ui style-->\r\n <ng-container *ngIf=\"isMaterialError; else withoutMaterial\">\r\n <ng-container *ngFor=\"let message of errorMessages\">\r\n <mat-error>{{ message }}</mat-error>\r\n </ng-container>\r\n </ng-container>\r\n\r\n <!--To show error messages in user style-->\r\n <ng-template #withoutMaterial>\r\n <div [ngClass]=\"ngxValidationConfig?.validationMessagesStyle?.blockClassNames || 'ngx_vm__def_error_block'\">\r\n <div *ngFor=\"let message of errorMessages\">\r\n <span [ngClass]=\"ngxValidationConfig?.validationMessagesStyle?.textClassNames || 'ngx_vm__def_error_text'\">\r\n {{ message }}\r\n </span>\r\n </div>\r\n </div>\r\n </ng-template>\r\n\r\n</ng-container>\r\n",
526
- 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"]
527
- },] }
528
- ];
529
- NgxValidationMessagesComponent.ctorParameters = function () { return [
530
- { type: undefined, decorators: [{ type: core.Inject, args: [NGX_VALIDATION_MESSAGES_CONFIG,] }] },
531
- { type: NgxValidationMessagesService },
532
- { type: core.ElementRef }
533
- ]; };
534
- NgxValidationMessagesComponent.propDecorators = {
535
- formControl: [{ type: core.Input, args: ['for',] }],
536
- customMsgComponent: [{ type: core.ContentChildren, args: [NgxCustomMessageComponent,] }],
537
- customMsgDirective: [{ type: core.ContentChildren, args: [NgxValidatorNameDirective,] }]
538
- };
539
-
540
- var NgxValidationMessagesModule = /** @class */ (function () {
541
- function NgxValidationMessagesModule() {
542
- }
543
- NgxValidationMessagesModule.forRoot = function (config) {
544
- return {
545
- ngModule: NgxValidationMessagesModule,
546
- providers: [
547
- NgxValidationMessagesService,
548
- {
549
- provide: NGX_VALIDATION_MESSAGES_CONFIG,
550
- useValue: config
551
- }
552
- ]
553
- };
554
- };
555
- return NgxValidationMessagesModule;
556
- }());
557
- NgxValidationMessagesModule.decorators = [
558
- { type: core.NgModule, args: [{
559
- imports: [
560
- common.CommonModule,
561
- formField.MatFormFieldModule
562
- ],
563
- declarations: [
564
- NgxValidationMessagesComponent,
565
- NgxCustomMessageComponent,
566
- NgxValidatorNameDirective
567
- ],
568
- exports: [
569
- NgxValidationMessagesComponent,
570
- NgxCustomMessageComponent,
571
- NgxValidatorNameDirective
572
- ]
573
- },] }
574
- ];
575
-
576
- /*
577
- * Public API Surface of ngx-validation-messages
578
- */
579
-
580
- /**
581
- * Generated bundle index. Do not edit.
582
- */
583
-
584
- exports.NGX_VALIDATION_MESSAGES_CONFIG = NGX_VALIDATION_MESSAGES_CONFIG;
585
- exports.NgxCustomMessageComponent = NgxCustomMessageComponent;
586
- exports.NgxValidationMessagesComponent = NgxValidationMessagesComponent;
587
- exports.NgxValidationMessagesModule = NgxValidationMessagesModule;
588
- exports.NgxValidatorNameDirective = NgxValidatorNameDirective;
589
- exports["ɵa"] = NgxValidationMessagesService;
590
-
591
- Object.defineProperty(exports, '__esModule', { value: true });
592
-
593
- }));
594
- //# sourceMappingURL=lagoshny-ngx-validation-messages.umd.js.map