|
1 | 1 | --- |
2 | | -title: ISBN |
| 2 | +title: isbn |
| 3 | +description: Creates an ISBN validation action. |
| 4 | +source: /actions/isbn/isbn.ts |
3 | 5 | contributors: |
4 | 6 | - ysknsid25 |
| 7 | + - fabian-hiller |
5 | 8 | --- |
6 | 9 |
|
7 | | -# ISBN |
| 10 | +import { ApiList, Property } from '~/components'; |
| 11 | +import { properties } from './properties'; |
8 | 12 |
|
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']} /> |
0 commit comments