Spec-Zone.ru › Valibot

notWords

Создаёт действие проверки на отсутствие слов.

const Action = v.notWords<TInput, TLocales, TRequirement, TMessage>(
  locales,
  requirement,
  message
);

Обобщённые типы

  • TInput extends string
  • TLocales extends Intl.LocalesArgument
  • TRequirement extends number
  • TMessage extends ErrorMessage<NotWordsIssue<TInput, TRequirement>> | undefined

Параметры

  • locales TLocales
  • requirement TRequirement
  • message TMessage

Пояснение

С помощью notWords можно проверить слова в строке на основе заданного locales. Если входные данные не соответствуют requirement, можно использовать message, чтобы настроить сообщение об ошибке.

Возвращаемое значение

  • Action NotWordsAction<TInput, TLocales, TRequirement, TMessage>

Примеры

В следующих примерах показано, как можно использовать notWords.

Схема notWords

Схема для проверки строки, содержащей больше или меньше 5 слов.

const NotWordsSchema = v.pipe(
  v.string(),
  v.notWords('en', 5, 'The string must not have 5 words.')
);

Связанные API

Следующие API можно комбинировать с notWords.

Схемы

any, custom, string

Методы

pipe

Утилиты

isOfKind, isOfType

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

Spec-Zone.ru

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