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 (21 loc) • 881 B
JavaScript
import {
setToDefaultLocale
} from "./chunk-OE3L7EKN.mjs";
// 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(
`[${(allowedSpecialChars ?? "*@$!#%&()^~{}").replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&")}]`
);
return (received, ctx) => {
if (!specialCharRegExp.test(received)) ctx.addIssue("special character", received, atLeastOneSpecialCharErrorKey);
};
};
atLeastOneSpecialChar.key = atLeastOneSpecialCharErrorKey;
atLeastOneSpecialChar.message = atLeastOneSpecialCharErrorMessage;
setToDefaultLocale(atLeastOneSpecialChar);
export {
atLeastOneSpecialChar
};
//# sourceMappingURL=chunk-OU5BTUDV.mjs.map