Spec-Zone.ru › Valibot

creditCard

Creates a credit card validation action.

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

Generics

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

Parameters

  • message TMessage

Explanation

With creditCard you can validate the formatting of a string. If the input is not a credit card, you can use message to customize the error message.

The following credit card providers are currently supported: American Express, Diners Card, Discover, JCB, Union Pay, Master Card, and Visa.

Returns

  • Action CreditCardAction<TInput, TMessage>

Examples

The following examples show how creditCard can be used.

Credit Card schema

Schema to validate a credit card.

const CreditCardSchema = v.pipe(
  v.string(),
  v.creditCard('The credit card is badly formatted.')
);

Related

The following APIs can be combined with creditCard.

Schemas

any, custom, string

Methods

pipe

Utils

isOfKind, isOfType

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

Spec-Zone.ru

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