Spec-Zone.ru › Valibot

notSize

Creates a not size validation action.

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

Generics

  • TInput extends SizeInput
  • TRequirement extends number
  • TMessage extends ErrorMessage<NotSizeIssue<TInput, TRequirement>> | undefined

Parameters

  • requirement TRequirement
  • message TMessage

Explanation

With notSize you can validate the size of a map, set or blob. If the input does not match the requirement, you can use message to customize the error message.

Returns

  • Action NotSizeAction<TInput, TRequirement, TMessage>

Examples

The following examples show how notSize can be used.

Blob size schema

Schema to validate a blob with less ore more then 10 MB.

const BlobSchema = v.pipe(
  v.blob(),
  v.notSize(10 * 1024 * 1024, 'The blob must not be 10 MB in size.')
);

Set size schema

Schema to validate a set with less ore more then 8 numbers.

const SetSchema = v.pipe(
  v.set(number()),
  v.notSize(8, 'The set must not contain 8 numbers.')
);

Related

The following APIs can be combined with notSize.

Schemas

any, blob, custom, file, instance, map, set, unknown

Methods

pipe

Utils

isOfKind, isOfType

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

Spec-Zone.ru

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