1 | "use strict";
|
2 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
3 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
4 | };
|
5 | Object.defineProperty(exports, "__esModule", { value: true });
|
6 | exports.MinLength = exports.minLength = exports.MIN_LENGTH = void 0;
|
7 | const ValidateBy_1 = require("../common/ValidateBy");
|
8 | const isLength_1 = __importDefault(require("validator/lib/isLength"));
|
9 | exports.MIN_LENGTH = 'minLength';
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | function minLength(value, min) {
|
15 | return typeof value === 'string' && (0, isLength_1.default)(value, { min });
|
16 | }
|
17 | exports.minLength = minLength;
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | function MinLength(min, validationOptions) {
|
23 | return (0, ValidateBy_1.ValidateBy)({
|
24 | name: exports.MIN_LENGTH,
|
25 | constraints: [min],
|
26 | validator: {
|
27 | validate: (value, args) => minLength(value, args.constraints[0]),
|
28 | defaultMessage: (0, ValidateBy_1.buildMessage)(eachPrefix => eachPrefix + '$property must be longer than or equal to $constraint1 characters', validationOptions),
|
29 | },
|
30 | }, validationOptions);
|
31 | }
|
32 | exports.MinLength = MinLength;
|
33 |
|
\ | No newline at end of file |