Skip to content

Home > @opengovsg/validators > createEmailSchema

createEmailSchema() function ​

Create a schema that validates emails against RFC 5322 and a whitelist of domains.

Signature:

typescript
createEmailSchema: (options?: EmailValidatorOptions) => z.ZodType<string>

Parameters ​

ParameterTypeDescription
optionsEmailValidatorOptions(Optional) The options to use for validation

Returns:

z.ZodType<string>

A Zod schema that validates emails according to the provided options

Exceptions ​

OptionsError If the options are invalid