UNPKG

1.55 kBJavaScriptView Raw
1"use strict";
2var __importDefault = (this && this.__importDefault) || function (mod) {
3 return (mod && mod.__esModule) ? mod : { "default": mod };
4};
5Object.defineProperty(exports, "__esModule", { value: true });
6exports.IsPassportNumber = exports.isPassportNumber = exports.IS_PASSPORT_NUMBER = void 0;
7const ValidateBy_1 = require("../common/ValidateBy");
8const isPassportNumber_1 = __importDefault(require("validator/lib/isPassportNumber"));
9exports.IS_PASSPORT_NUMBER = 'isPassportNumber';
10/**
11 * Check if the string is a valid passport number relative to a specific country code.
12 * If given value is not a string, then it returns false.
13 */
14function isPassportNumber(value, countryCode) {
15 return typeof value === 'string' && (0, isPassportNumber_1.default)(value, countryCode);
16}
17exports.isPassportNumber = isPassportNumber;
18/**
19 * Check if the string is a valid passport number relative to a specific country code.
20 * If given value is not a string, then it returns false.
21 */
22function IsPassportNumber(countryCode, validationOptions) {
23 return (0, ValidateBy_1.ValidateBy)({
24 name: exports.IS_PASSPORT_NUMBER,
25 constraints: [countryCode],
26 validator: {
27 validate: (value, args) => isPassportNumber(value, args.constraints[0]),
28 defaultMessage: (0, ValidateBy_1.buildMessage)(eachPrefix => eachPrefix + '$property must be valid passport number', validationOptions),
29 },
30 }, validationOptions);
31}
32exports.IsPassportNumber = IsPassportNumber;
33//# sourceMappingURL=IsPassportNumber.js.map
\No newline at end of file