isbn
Creates an ISBN validation action.
const Action = v.isbn<TInput, TMessage>(message);
Generics
TInputextends stringTMessageextends ErrorMessage<IsbnIssue<TInput>> | undefined
Parameters
messageTMessage
Explanation
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.
This action supports both ISBN-10 and ISBN-13 formats and accepts hyphens and spaces as separators.
Returns
ActionIsbnAction<TInput, TMessage>
Examples
The following examples show how isbn can be used.
ISBN schema
Schema to validate an ISBN.
const IsbnSchema = v.pipe(v.string(), v.isbn('The ISBN is badly formatted'));
// Valid ISBN-10 formats:
// '0-306-40615-2'
// '0306406152'
// '0 306 40615 2'
// Valid ISBN-13 formats:
// '978-0-306-40615-7'
// '9780306406157'
// '978 0 306 40615 7'
Related
The following APIs can be combined with isbn.
Schemas
Methods
Utils
© Fabian Hiller
Licensed under the MIT License.
https://valibot.dev/api/isbn/