-
-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/use-interface-for-base-types
- Loading branch information
Showing
5 changed files
with
130 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
title: EmailValidation | ||
description: Email validation type. | ||
contributors: | ||
- fabian-hiller | ||
--- | ||
|
||
import { Property } from '~/components'; | ||
import { properties } from './properties'; | ||
|
||
# EmailValidation | ||
|
||
Email validation type. | ||
|
||
## Definition | ||
|
||
- `EmailValidation` <Property {...properties.BaseValidation} /> | ||
- `type` <Property {...properties.type} /> | ||
- `requirement` <Property {...properties.requirement} /> |
31 changes: 31 additions & 0 deletions
31
website/src/routes/api/(types)/EmailValidation/properties.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import type { PropertyProps } from '~/components'; | ||
|
||
export const properties: Record<string, PropertyProps> = { | ||
BaseValidation: { | ||
type: [ | ||
{ | ||
type: 'custom', | ||
name: 'BaseValidation', | ||
href: '../BaseValidation/', | ||
generics: [ | ||
{ | ||
type: 'custom', | ||
name: 'TInput', | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
type: { | ||
type: { | ||
type: 'string', | ||
value: 'email', | ||
}, | ||
}, | ||
requirement: { | ||
type: { | ||
type: 'custom', | ||
name: 'RegExp', | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,58 @@ | ||
--- | ||
title: email | ||
description: Creates a pipeline validation action that validates an email. | ||
source: /validations/email/email.ts | ||
contributors: | ||
- fabian-hiller | ||
--- | ||
|
||
import { ApiList, Property } from '~/components'; | ||
import { properties } from './properties'; | ||
|
||
|
||
> The content of this page is not yet ready. Until then, please use the [source code](https://github.com/fabian-hiller/valibot/blob/main/library/src/validations/email/email.ts) or take a look at [issue #287](https://github.com/fabian-hiller/valibot/issues/287) to help us extend the API reference. | ||
Creates a pipeline validation action that validates an email. | ||
|
||
```ts | ||
const Validation = email<TInput>(message); | ||
``` | ||
|
||
## Generics | ||
|
||
- `TInput` <Property {...properties.TInput} /> | ||
|
||
## Parameters | ||
|
||
- `message` <Property {...properties.message} /> | ||
|
||
### Explanation | ||
|
||
With `email` you can validate the formatting of a string. If the input is not an email, you can use `message` to customize the error message. | ||
|
||
## Returns | ||
|
||
- `Validation` <Property {...properties.Validation} /> | ||
|
||
## Examples | ||
|
||
The following examples show how `email` can be used. | ||
|
||
### Email schema | ||
|
||
Schema to validate an email. | ||
|
||
```ts | ||
const EmailSchema = string([ | ||
minLength(1, 'Please enter your email.'), | ||
email('The email is badly formatted.'), | ||
maxLength(30, 'Your email is too long.'), | ||
]); | ||
``` | ||
|
||
## Related | ||
|
||
The following APIs can be combined with `email`. | ||
|
||
### Schemas | ||
|
||
<ApiList items={['any', 'string', 'unknown']} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import type { PropertyProps } from '~/components'; | ||
|
||
export const properties: Record<string, PropertyProps> = { | ||
TInput: { | ||
type: 'string', | ||
}, | ||
message: { | ||
type: [ | ||
{ | ||
type: 'custom', | ||
name: 'ErrorMessage', | ||
href: '../ErrorMessage/', | ||
}, | ||
'undefined', | ||
], | ||
default: { | ||
type: 'string', | ||
value: 'Invalid email', | ||
}, | ||
}, | ||
Validation: { | ||
type: [ | ||
{ | ||
type: 'custom', | ||
name: 'EmailValidation', | ||
href: '../EmailValidation/', | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters