以下のようにすることでファイル拡張子のバリデーションを設定できます。
const schema = z.object({
avatar: z
.any()
.refine(
(files) => ['image/jpeg', 'image/png'].includes(files?.[0]?.type),
'.jpg, .jpeg, .pngのファイルを選択してください。'
),
})
Go to list of users who liked
More than 1 year has passed since last update.
以下のようにすることでファイル拡張子のバリデーションを設定できます。
const schema = z.object({
avatar: z
.any()
.refine(
(files) => ['image/jpeg', 'image/png'].includes(files?.[0]?.type),
'.jpg, .jpeg, .pngのファイルを選択してください。'
),
})
Register as a new user and use Qiita more conveniently
Go to list of users who liked