Spec-Zone.ru › Valibot

isbn

Creates an ISBN validation action.

const Action = v.isbn<TInput, TMessage>(message);

Generics

  • TInput extends string
  • TMessage extends ErrorMessage<IsbnIssue<TInput>> | undefined

Parameters

  • message TMessage

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

  • Action IsbnAction<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

any, custom, string

Methods

pipe

Utils

isOfKind, isOfType

© Fabian Hiller
Licensed under the MIT License.
https://valibot.dev/api/isbn/

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API