UNPKG

1.23 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.IsIBAN = exports.isIBAN = exports.IS_IBAN = void 0;
7const ValidateBy_1 = require("../common/ValidateBy");
8const isIBAN_1 = __importDefault(require("validator/lib/isIBAN"));
9exports.IS_IBAN = 'isIBAN';
10/**
11 * Check if a string is a IBAN (International Bank Account Number).
12 * If given value is not a string, then it returns false.
13 */
14function isIBAN(value) {
15 return typeof value === 'string' && (0, isIBAN_1.default)(value);
16}
17exports.isIBAN = isIBAN;
18/**
19 * Check if a string is a IBAN (International Bank Account Number).
20 * If given value is not a string, then it returns false.
21 */
22function IsIBAN(validationOptions) {
23 return (0, ValidateBy_1.ValidateBy)({
24 name: exports.IS_IBAN,
25 validator: {
26 validate: (value, args) => isIBAN(value),
27 defaultMessage: (0, ValidateBy_1.buildMessage)(eachPrefix => eachPrefix + '$property must be an IBAN', validationOptions),
28 },
29 }, validationOptions);
30}
31exports.IsIBAN = IsIBAN;
32//# sourceMappingURL=IsIBAN.js.map
\No newline at end of file