mimeType
Creates a MIME type validation action.
const Action = v.mimeType<TInput, TRequirement, TMessage>(requirement, message);
Generics
TInputextends BlobTRequirementextends string[]TMessageextends ErrorMessage<MimeTypeIssue<TInput, TRequirement>> | undefined
Parameters
requirementTRequirementmessageTMessage
Explanation
With mimeType you can validate the MIME type of a blob. If the input does not match the requirement, you can use message to customize the error message.
Returns
ActionMimeTypeAction<TInput, TRequirement, TMessage>
Examples
The following examples show how mimeType can be used.
Image schema
Schema to validate an image file.
const ImageSchema = v.pipe(
v.blob(),
v.mimeType(['image/jpeg', 'image/png'], 'Please select a JPEG or PNG file.')
);
Related
The following APIs can be combined with mimeType.
Schemas
any, blob, custom, file, instance, unknown
Methods
Utils
© Fabian Hiller
Licensed under the MIT License.
https://valibot.dev/api/mimeType/