UNPKG

fe-validate

Version:

angular 2+ form validate

69 lines (68 loc) 2.58 kB
/** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ import { Inject, Injectable } from "@angular/core"; import { ErrorMessage } from "./message.models"; import { DEFAULT_ERRORS } from "./default-errors"; import { CUSTOM_ERROR_MESSAGES } from "./tokens"; var ErrorMessageService = /** @class */ (function () { function ErrorMessageService(customErrorMessages) { if (customErrorMessages === void 0) { customErrorMessages = []; } this.customErrorMessages = customErrorMessages; } Object.defineProperty(ErrorMessageService.prototype, "errorMessages", { get: /** * @return {?} */ function () { return this.mergeArray(this.customErrorMessages, this.defaultErrors); }, enumerable: true, configurable: true }); /** * @param {?=} customErrorMessages * @param {?=} defaultErrors * @return {?} */ ErrorMessageService.prototype.mergeArray = /** * @param {?=} customErrorMessages * @param {?=} defaultErrors * @return {?} */ function (customErrorMessages, defaultErrors) { if (customErrorMessages === void 0) { customErrorMessages = []; } if (defaultErrors === void 0) { defaultErrors = []; } var /** @type {?} */ tmpArray = []; for (var _i = 0, defaultErrors_1 = defaultErrors; _i < defaultErrors_1.length; _i++) { var defObj = defaultErrors_1[_i]; var /** @type {?} */ includeFlag = false; for (var _a = 0, customErrorMessages_1 = customErrorMessages; _a < customErrorMessages_1.length; _a++) { var customObj = customErrorMessages_1[_a]; if (defObj.error === customObj.error) { includeFlag = true; } } if (!includeFlag) { tmpArray.push(defObj); } } return tmpArray.concat(customErrorMessages || []); }; return ErrorMessageService; }()); export { ErrorMessageService }; function ErrorMessageService_tsickle_Closure_declarations() { /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */ ErrorMessageService.decorators; /** * @nocollapse * @type {function(): !Array<(null|{type: ?, decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>)})>} */ ErrorMessageService.ctorParameters; /** @type {?} */ ErrorMessageService.prototype.defaultErrors; /** @type {?} */ ErrorMessageService.prototype.customErrorMessages; }