1 | ;
|
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.IsPostalCode = exports.isPostalCode = exports.IS_POSTAL_CODE = void 0;
|
7 | const ValidateBy_1 = require("../common/ValidateBy");
|
8 | const isPostalCode_1 = __importDefault(require("validator/lib/isPostalCode"));
|
9 | exports.IS_POSTAL_CODE = 'isPostalCode';
|
10 | /**
|
11 | * Check if the string is a postal code,
|
12 | * (locale is one of [ 'AD', 'AT', 'AU', 'BE', 'BG', 'BR', 'CA', 'CH', 'CZ', 'DE', 'DK', 'DZ', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HU', 'ID', 'IE' 'IL', 'IN', 'IR', 'IS', 'IT', 'JP', 'KE', 'LI', 'LT', 'LU', 'LV', 'MT', 'MX', 'NL', 'NO', 'NZ', 'PL', 'PR', 'PT', 'RO', 'RU', 'SA', 'SE', 'SI', 'TN', 'TW', 'UA', 'US', 'ZA', 'ZM' ] OR 'any'. If 'any' is used, function will check if any of the locals match. Locale list is validator.isPostalCodeLocales.).
|
13 | * If given value is not a string, then it returns false.
|
14 | */
|
15 | function isPostalCode(value, locale) {
|
16 | return typeof value === 'string' && (0, isPostalCode_1.default)(value, locale);
|
17 | }
|
18 | exports.isPostalCode = isPostalCode;
|
19 | /**
|
20 | * Check if the string is a postal code,
|
21 | * (locale is one of [ 'AD', 'AT', 'AU', 'BE', 'BG', 'BR', 'CA', 'CH', 'CZ', 'DE', 'DK', 'DZ', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HU', 'ID', 'IE' 'IL', 'IN', 'IR', 'IS', 'IT', 'JP', 'KE', 'LI', 'LT', 'LU', 'LV', 'MT', 'MX', 'NL', 'NO', 'NZ', 'PL', 'PR', 'PT', 'RO', 'RU', 'SA', 'SE', 'SI', 'TN', 'TW', 'UA', 'US', 'ZA', 'ZM' ] OR 'any'. If 'any' is used, function will check if any of the locals match. Locale list is validator.isPostalCodeLocales.).
|
22 | * If given value is not a string, then it returns false.
|
23 | */
|
24 | function IsPostalCode(locale, validationOptions) {
|
25 | return (0, ValidateBy_1.ValidateBy)({
|
26 | name: exports.IS_POSTAL_CODE,
|
27 | constraints: [locale],
|
28 | validator: {
|
29 | validate: (value, args) => isPostalCode(value, args.constraints[0]),
|
30 | defaultMessage: (0, ValidateBy_1.buildMessage)(eachPrefix => eachPrefix + '$property must be a postal code', validationOptions),
|
31 | },
|
32 | }, validationOptions);
|
33 | }
|
34 | exports.IsPostalCode = IsPostalCode;
|
35 | //# sourceMappingURL=IsPostalCode.js.map |
\ | No newline at end of file |