Skip to content

Commit 6c7f9c0

Browse files
committed
Add docs for new isbn action to website
1 parent ca902e6 commit 6c7f9c0

File tree

23 files changed

+363
-3
lines changed

23 files changed

+363
-3
lines changed
Lines changed: 70 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,76 @@
11
---
2-
title: ISBN
2+
title: isbn
3+
description: Creates an ISBN validation action.
4+
source: /actions/isbn/isbn.ts
35
contributors:
46
- ysknsid25
7+
- fabian-hiller
58
---
69

7-
# ISBN
10+
import { ApiList, Property } from '~/components';
11+
import { properties } from './properties';
812

9-
> The content of this page is not yet ready. Until then just use the [source code](https://github.com/fabian-hiller/valibot/blob/main/library/src/actions/isbn/isbn.ts).
13+
# isbn
14+
15+
Creates an [ISBN](https://en.wikipedia.org/wiki/ISBN) validation action.
16+
17+
```ts
18+
const Action = v.isbn<TInput, TMessage>(message);
19+
```
20+
21+
## Generics
22+
23+
- `TInput` <Property {...properties.TInput} />
24+
- `TMessage` <Property {...properties.TMessage} />
25+
26+
## Parameters
27+
28+
- `message` <Property {...properties.message} />
29+
30+
### Explanation
31+
32+
With `isbn` you can validate the formatting of a string. If the input is not an ISBN, you can use `message` to customize the error message.
33+
34+
This action supports both ISBN-10 and ISBN-13 formats and accepts hyphens and spaces as separators.
35+
36+
## Returns
37+
38+
- `Action` <Property {...properties.Action} />
39+
40+
## Examples
41+
42+
The following examples show how `isbn` can be used.
43+
44+
### ISBN schema
45+
46+
Schema to validate an ISBN.
47+
48+
```ts
49+
const IsbnSchema = v.pipe(v.string(), v.isbn('The ISBN is badly formatted'));
50+
51+
// Valid ISBN-10 formats:
52+
// '0-306-40615-2'
53+
// '0306406152'
54+
// '0 306 40615 2'
55+
56+
// Valid ISBN-13 formats:
57+
// '978-0-306-40615-7'
58+
// '9780306406157'
59+
// '978 0 306 40615 7'
60+
```
61+
62+
## Related
63+
64+
The following APIs can be combined with `isbn`.
65+
66+
### Schemas
67+
68+
<ApiList items={['any', 'custom', 'string']} />
69+
70+
### Methods
71+
72+
<ApiList items={['pipe']} />
73+
74+
### Utils
75+
76+
<ApiList items={['isOfKind', 'isOfType']} />
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import type { PropertyProps } from '~/components';
2+
3+
export const properties: Record<string, PropertyProps> = {
4+
TInput: {
5+
modifier: 'extends',
6+
type: 'string',
7+
},
8+
TMessage: {
9+
modifier: 'extends',
10+
type: {
11+
type: 'union',
12+
options: [
13+
{
14+
type: 'custom',
15+
name: 'ErrorMessage',
16+
href: '../ErrorMessage/',
17+
generics: [
18+
{
19+
type: 'custom',
20+
name: 'IsbnIssue',
21+
href: '../IsbnIssue/',
22+
generics: [
23+
{
24+
type: 'custom',
25+
name: 'TInput',
26+
},
27+
],
28+
},
29+
],
30+
},
31+
'undefined',
32+
],
33+
},
34+
},
35+
message: {
36+
type: {
37+
type: 'custom',
38+
name: 'TMessage',
39+
},
40+
},
41+
Action: {
42+
type: {
43+
type: 'custom',
44+
name: 'IsbnAction',
45+
href: '../IsbnAction/',
46+
generics: [
47+
{
48+
type: 'custom',
49+
name: 'TInput',
50+
},
51+
{
52+
type: 'custom',
53+
name: 'TMessage',
54+
},
55+
],
56+
},
57+
},
58+
};

website/src/routes/api/(async)/customAsync/index.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ The following APIs can be combined with `customAsync`.
141141
'ip',
142142
'ipv4',
143143
'ipv6',
144+
'isbn',
144145
'isoDate',
145146
'isoDateTime',
146147
'isoTime',

website/src/routes/api/(async)/fallbackAsync/index.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ The following APIs can be combined with `fallbackAsync`.
169169
'ip',
170170
'ipv4',
171171
'ipv6',
172+
'isbn',
172173
'isoDate',
173174
'isoDateTime',
174175
'isoTime',

website/src/routes/api/(async)/intersectAsync/index.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ The following APIs can be combined with `intersectAsync`.
171171
'ip',
172172
'ipv4',
173173
'ipv6',
174+
'isbn',
174175
'isoDate',
175176
'isoDateTime',
176177
'isoTime',

website/src/routes/api/(async)/lazyAsync/index.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ The following APIs can be combined with `lazyAsync`.
203203
'ip',
204204
'ipv4',
205205
'ipv6',
206+
'isbn',
206207
'isoDate',
207208
'isoDateTime',
208209
'isoTime',

website/src/routes/api/(async)/pipeAsync/index.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ The following APIs can be combined with `pipeAsync`.
208208
'ip',
209209
'ipv4',
210210
'ipv6',
211+
'isbn',
211212
'isoDate',
212213
'isoDateTime',
213214
'isoTime',

website/src/routes/api/(async)/unionAsync/index.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ The following APIs can be combined with `unionAsync`.
164164
'ip',
165165
'ipv4',
166166
'ipv6',
167+
'isbn',
167168
'isoDate',
168169
'isoDateTime',
169170
'isoTime',

website/src/routes/api/(methods)/config/index.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ The following APIs can be combined with `config`.
188188
'ip',
189189
'ipv4',
190190
'ipv6',
191+
'isbn',
191192
'isoDate',
192193
'isoDateTime',
193194
'isoTime',

website/src/routes/api/(methods)/fallback/index.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ The following APIs can be combined with `fallback`.
186186
'ip',
187187
'ipv4',
188188
'ipv6',
189+
'isbn',
189190
'isoDate',
190191
'isoDateTime',
191192
'isoTime',

0 commit comments

Comments
 (0)