UNPKG

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