Const
The schema is registered in the BupkisRegistry
with the name RegExp
for
later reference and type checking purposes.
RegExpSchema.parse(/abc/gi); // ✓ Valid (literal syntax)
RegExpSchema.parse(new RegExp('abc', 'gi')); // ✓ Valid (constructor)
RegExpSchema.parse(/test/); // ✓ Valid (no flags)
RegExpSchema.parse(new RegExp('')); // ✓ Valid (empty pattern)
RegExpSchema.parse('abc'); // ✗ Throws validation error (string)
RegExpSchema.parse(/abc/.source); // ✗ Throws validation error (string pattern)
RegExpSchema.parse({}); // ✗ Throws validation error (object)
A Zod schema that validates RegExp instances.
This schema validates values that are instances of the RegExp class, including regular expressions created with both literal syntax (
/pattern/flags
) and the RegExp constructor (new RegExp(pattern, flags)
). It ensures the validated value is a proper regular expression object with all associated methods and properties.