empty
Creates an empty validation action.
const Action = v.empty<TInput, TMessage>(requirement, message);
Generics
TInputextends LengthInputTMessageextends ErrorMessage<EmptyIssue<TInput>> | undefined
Parameters
messageTMessage
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
ActionEmptyAction<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
Utils
© Fabian Hiller
Licensed under the MIT License.
https://valibot.dev/api/empty/