UNPKG

validator-list

Version:
22 lines (21 loc) 779 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AsyncCompareValidator = void 0; const _ = require("lodash"); const base_compare_validator_1 = require("./base-compare-validator"); class AsyncCompareValidator extends base_compare_validator_1.BaseCompareValidator { async validate() { if (!this.isAvailableForValidation()) { return false; } let compareValue = this.compareValue; if (_.isFunction(this.compareValue)) { compareValue = await this.compareValue(); } if (!this.copmare(compareValue)) { return this.message.replace('{attribute}', this.attributeLabel); } return false; } } exports.AsyncCompareValidator = AsyncCompareValidator;