1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.IsNotIn = exports.isNotIn = exports.IS_NOT_IN = void 0;
|
4 | const ValidateBy_1 = require("../common/ValidateBy");
|
5 | exports.IS_NOT_IN = 'isNotIn';
|
6 |
|
7 |
|
8 |
|
9 | function isNotIn(value, possibleValues) {
|
10 | return !Array.isArray(possibleValues) || !possibleValues.some(possibleValue => possibleValue === value);
|
11 | }
|
12 | exports.isNotIn = isNotIn;
|
13 |
|
14 |
|
15 |
|
16 | function IsNotIn(values, validationOptions) {
|
17 | return (0, ValidateBy_1.ValidateBy)({
|
18 | name: exports.IS_NOT_IN,
|
19 | constraints: [values],
|
20 | validator: {
|
21 | validate: (value, args) => isNotIn(value, args.constraints[0]),
|
22 | defaultMessage: (0, ValidateBy_1.buildMessage)(eachPrefix => eachPrefix + '$property should not be one of the following values: $constraint1', validationOptions),
|
23 | },
|
24 | }, validationOptions);
|
25 | }
|
26 | exports.IsNotIn = IsNotIn;
|
27 |
|
\ | No newline at end of file |