Skip to content

Commit

Permalink
fix(input): add zod for input card
Browse files Browse the repository at this point in the history
  • Loading branch information
jacc committed Nov 7, 2024
1 parent 53582e0 commit cbf71bb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/components/cards/bundle-item-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { usePlayers } from "@/contexts/players-context";
import { BundleItemWithLocation } from "@/types/bundles";
import { BooleanCard } from "./boolean-card";
import { categoryIcons, goldIcons } from "@/lib/constants";
import { unknown } from "valibot";

interface BundleItemCardProps {
item: BundleItemWithLocation;
Expand Down
10 changes: 5 additions & 5 deletions src/components/cards/input-card.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// This is only used for monster slayer goals so it's not very reusable

import * as v from "valibot";
import * as z from "zod";
import Image from "next/image";

import { cn } from "@/lib/utils";
import { useState } from "react";
import { useForm } from "react-hook-form";
import { usePlayers } from "@/contexts/players-context";
import { valibotResolver } from "@hookform/resolvers/valibot";
import { zodResolver } from "@hookform/resolvers/zod";

import {
Form,
Expand Down Expand Up @@ -46,12 +46,12 @@ export const InputCard = ({
}: Props) => {
const [value, setValue] = useState(0);

const inputSchema = v.object({
input: v.pipe(v.number(), v.minValue(0)),
const inputSchema = z.object({
input: z.coerce.number().min(10),
});

const form = useForm({
resolver: valibotResolver(inputSchema),
resolver: zodResolver(inputSchema),
});

async function handleSave() {
Expand Down

0 comments on commit cbf71bb

Please sign in to comment.