PromoCursed/node_modules/@rc-component/async-validator/lib/rule/enum.js
2024-08-20 23:25:37 +04:00

15 lines
486 B
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _util = require("../util");
var ENUM = 'enum';
var enumerable = function enumerable(rule, value, source, errors, options) {
rule[ENUM] = Array.isArray(rule[ENUM]) ? rule[ENUM] : [];
if (rule[ENUM].indexOf(value) === -1) {
errors.push((0, _util.format)(options.messages[ENUM], rule.fullField, rule[ENUM].join(', ')));
}
};
var _default = exports.default = enumerable;