UNPKG

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.

24 lines (21 loc) 880 B
import { RequiredValidation } from '../../core.mjs'; import '../../commonTypes.mjs'; import '../../InferType.mjs'; import '../../helpers/constants.mjs'; /** * @description Asserts that a string value matches the email pattern. The pattern checks for a basic email format. * @returns {RequiredValidation} A validation function that takes a received string and an exception context. * @throws {ValidationError} if the received value does not match the email pattern. * @example * const schema = string().custom(email()); * parseOrFail(schema, 'example@example.com'); // Valid * parseOrFail(schema, 'invalid-email'); // Throws an error: 'The received value does not match the required email pattern' * * @translation - Error Translation Key = 's:email' */ declare const email: { (): RequiredValidation; key: string; message: string; }; export { email };