Skip to content

How to convert zod image scheme to valibot image scheme? #754

Answered by fabian-hiller
Enkratia asked this question in Q&A
Discussion options

You must be logged in to vote

This will work in the next version of Valibot:

import * as v from 'valibot';

const Schema = v.optional(
  v.pipe(v.instance(FileList), v.nonEmpty('Please upload one or more images'))
);

For the current version use:

import * as v from 'valibot';

const Schema = v.optional(
  v.pipe(
    v.instance(FileList),
    v.check((files) => !!files.length, 'Please upload one or more images')
  )
);

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Enkratia
Comment options

Answer selected by Enkratia
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants