bguard
Version:
**bguard** is a powerful, flexible, and type-safe validation library for TypeScript. It allows developers to define validation schemas for their data structures and ensures that data conforms to the expected types and constraints.
23 lines (18 loc) • 1.13 kB
JavaScript
;Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
var _chunkTJQ5NVL4js = require('./chunk-TJQ5NVL4.js');
// src/asserts/string/atLeastOneSpecialChar.ts
var atLeastOneSpecialCharErrorMessage = "The received value does not contain at least one special character";
var atLeastOneSpecialCharErrorKey = "s:atLeastOneSpecialChar";
var atLeastOneSpecialChar = (allowedSpecialChars) => {
const specialCharRegExp = new RegExp(
`[${(_nullishCoalesce(allowedSpecialChars, () => ( "*@$!#%&()^~{}"))).replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&")}]`
);
return (received, ctx) => {
if (!specialCharRegExp.test(received)) ctx.addIssue("special character", received, atLeastOneSpecialCharErrorKey);
};
};
atLeastOneSpecialChar.key = atLeastOneSpecialCharErrorKey;
atLeastOneSpecialChar.message = atLeastOneSpecialCharErrorMessage;
_chunkTJQ5NVL4js.setToDefaultLocale.call(void 0, atLeastOneSpecialChar);
exports.atLeastOneSpecialChar = atLeastOneSpecialChar;
//# sourceMappingURL=chunk-PVQALO2H.js.map