Skip to content

Commit

Permalink
refactor: provide zod schema
Browse files Browse the repository at this point in the history
  • Loading branch information
zeyu2001 committed Aug 1, 2024
1 parent f8a0458 commit dc15f8d
Show file tree
Hide file tree
Showing 20 changed files with 190 additions and 631 deletions.
59 changes: 59 additions & 0 deletions apps/docs/api/starter-kitty-validators.createemailschema.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@opengovsg/starter-kitty-validators](./starter-kitty-validators.md) &gt; [createEmailSchema](./starter-kitty-validators.createemailschema.md)

## createEmailSchema() function

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

**Signature:**

```typescript
createEmailSchema: (options?: EmailValidatorOptions) => ZodSchema<string>
```

## Parameters

<table><thead><tr><th>

Parameter


</th><th>

Type


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

options


</td><td>

[EmailValidatorOptions](./starter-kitty-validators.emailvalidatoroptions.md)


</td><td>

_(Optional)_ The options to use for validation


</td></tr>
</tbody></table>
**Returns:**

ZodSchema&lt;string&gt;

A Zod schema that validates emails according to the provided options

## Exceptions

[OptionsError](./starter-kitty-validators.optionserror.md) If the options are invalid

This file was deleted.

48 changes: 0 additions & 48 deletions apps/docs/api/starter-kitty-validators.emailvalidationerror.md

This file was deleted.

This file was deleted.

81 changes: 0 additions & 81 deletions apps/docs/api/starter-kitty-validators.emailvalidator.md

This file was deleted.

58 changes: 0 additions & 58 deletions apps/docs/api/starter-kitty-validators.emailvalidator.parse.md

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,22 @@

The list of allowed domains for the domain part of the email address. If not provided, all domains are allowed.

Each whitelisted domain must be specified as an object with the `domain` and `includeSubdomains` properties. If `includeSubdomains` is `true`<!-- -->, all subdomains of the domain are also allowed.

**Signature:**

```typescript
domains?: string[];
domains?: {
domain: string;
includeSubdomains: boolean;
}[];
```

## Example

`[ 'gov.sg', 'example.com' ]`

```javascript
[ { domain: 'gov.sg', includeSubdomains: true } ]
```
This will allow `gov.sg` and all subdomains of `gov.sg`<!-- -->, such as `open.gov.sg`<!-- -->.

Loading

0 comments on commit dc15f8d

Please sign in to comment.