Spec-Zone.ru › Valibot

empty

Creates an empty validation action.

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

Generics

  • TInput extends LengthInput
  • TMessage extends ErrorMessage<EmptyIssue<TInput>> | undefined

Parameters

  • message TMessage

Explanation

With empty you can validate that a string or array is empty. If the input is not empty, you can use message to customize the error message.

Returns

  • Action EmptyAction<TInput, TMessage>

Examples

The following examples show how empty can be used.

String schema

Schema to validate that a string is empty.

const StringSchema = v.pipe(v.string(), v.empty('The string must be empty.'));

Array schema

Schema to validate that an array is empty.

const ArraySchema = v.pipe(
  v.array(v.number()),
  v.empty('The array must be empty.')
);

Related

The following APIs can be combined with empty.

Schemas

any, array, custom, instance, string, tuple, unknown

Methods

pipe

Utils

isOfKind, isOfType

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

Spec-Zone.ru

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