Skip to content

Commit

Permalink
doc: email validator
Browse files Browse the repository at this point in the history
  • Loading branch information
zeyu2001 committed Aug 1, 2024
1 parent 5d1ba3f commit 8abcc74
Show file tree
Hide file tree
Showing 31 changed files with 774 additions and 182 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<!-- 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; [OptionsError](./starter-kitty-validators.optionserror.md) &gt; [(constructor)](./starter-kitty-validators.optionserror._constructor_.md)
[Home](./index.md) &gt; [@opengovsg/starter-kitty-validators](./starter-kitty-validators.md) &gt; [EmailValidationError](./starter-kitty-validators.emailvalidationerror.md) &gt; [(constructor)](./starter-kitty-validators.emailvalidationerror._constructor_.md)

## OptionsError.(constructor)
## EmailValidationError.(constructor)

Constructs a new instance of the `OptionsError` class
Constructs a new instance of the `EmailValidationError` class

**Signature:**

Expand Down
48 changes: 48 additions & 0 deletions apps/docs/api/starter-kitty-validators.emailvalidationerror.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!-- 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; [EmailValidationError](./starter-kitty-validators.emailvalidationerror.md)

## EmailValidationError class

Invalid email error.

**Signature:**

```typescript
export declare class EmailValidationError extends Error
```
**Extends:** Error
## Constructors
<table><thead><tr><th>
Constructor
</th><th>
Modifiers
</th><th>
Description
</th></tr></thead>
<tbody><tr><td>
[(constructor)(message)](./starter-kitty-validators.emailvalidationerror._constructor_.md)
</td><td>
</td><td>
Constructs a new instance of the `EmailValidationError` class
</td></tr>
</tbody></table>
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!-- 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; [EmailValidator](./starter-kitty-validators.emailvalidator.md) &gt; [(constructor)](./starter-kitty-validators.emailvalidator._constructor_.md)

## EmailValidator.(constructor)

Constructs a new instance of the `EmailValidator` class

**Signature:**

```typescript
constructor(options?: EmailValidatorOptions);
```

## 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)_


</td></tr>
</tbody></table>
81 changes: 81 additions & 0 deletions apps/docs/api/starter-kitty-validators.emailvalidator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<!-- 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; [EmailValidator](./starter-kitty-validators.emailvalidator.md)

## EmailValidator class

Validates emails against RFC 5322 and a whitelist of domains.

**Signature:**

```typescript
export declare class EmailValidator
```

## Constructors

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

Constructor


</th><th>

Modifiers


</th><th>

Description


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

[(constructor)(options)](./starter-kitty-validators.emailvalidator._constructor_.md)


</td><td>


</td><td>

Constructs a new instance of the `EmailValidator` class


</td></tr>
</tbody></table>

## Methods

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

Method


</th><th>

Modifiers


</th><th>

Description


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

[parse(email)](./starter-kitty-validators.emailvalidator.parse.md)


</td><td>


</td><td>

Parses an email address string.


</td></tr>
</tbody></table>
58 changes: 58 additions & 0 deletions apps/docs/api/starter-kitty-validators.emailvalidator.parse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<!-- 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; [EmailValidator](./starter-kitty-validators.emailvalidator.md) &gt; [parse](./starter-kitty-validators.emailvalidator.parse.md)

## EmailValidator.parse() method

Parses an email address string.

**Signature:**

```typescript
parse(email: string): string;
```

## Parameters

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

Parameter


</th><th>

Type


</th><th>

Description


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

email


</td><td>

string


</td><td>

The email to validate


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

string


## Exceptions

[EmailValidationError](./starter-kitty-validators.emailvalidationerror.md) If the email is invalid

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!-- 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; [EmailValidatorOptions](./starter-kitty-validators.emailvalidatoroptions.md) &gt; [allowSubdomains](./starter-kitty-validators.emailvalidatoroptions.allowsubdomains.md)

## EmailValidatorOptions.allowSubdomains property

Whether subdomains are allowed. Defaults to `true`<!-- -->.

**Signature:**

```typescript
allowSubdomains?: boolean;
```

## Example

If `false`<!-- -->, `open.gov.sg` is not allowed, even if `gov.sg` is in the whitelist.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!-- 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; [EmailValidatorOptions](./starter-kitty-validators.emailvalidatoroptions.md) &gt; [domains](./starter-kitty-validators.emailvalidatoroptions.domains.md)

## EmailValidatorOptions.domains property

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

**Signature:**

```typescript
domains?: string[];
```

## Example

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

76 changes: 76 additions & 0 deletions apps/docs/api/starter-kitty-validators.emailvalidatoroptions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<!-- 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; [EmailValidatorOptions](./starter-kitty-validators.emailvalidatoroptions.md)

## EmailValidatorOptions interface

The options to use for email validation.

**Signature:**

```typescript
export interface EmailValidatorOptions
```

## Properties

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

Property


</th><th>

Modifiers


</th><th>

Type


</th><th>

Description


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

[allowSubdomains?](./starter-kitty-validators.emailvalidatoroptions.allowsubdomains.md)


</td><td>


</td><td>

boolean


</td><td>

_(Optional)_ Whether subdomains are allowed. Defaults to `true`<!-- -->.


</td></tr>
<tr><td>

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


</td><td>


</td><td>

string\[\]


</td><td>

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


</td></tr>
</tbody></table>
Loading

0 comments on commit 8abcc74

Please sign in to comment.