diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7196d9314..2f2744596 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -59,7 +59,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node: ["14"] + node: ["18"] name: Lint on Node ${{ matrix.node }} steps: - uses: actions/checkout@v2 diff --git a/playground.ts b/playground.ts index 1e7492646..a512dcd78 100644 --- a/playground.ts +++ b/playground.ts @@ -1,32 +1 @@ -import { Schema, z } from "./src"; - -async function main() { - const dateRangeValidator = (val: { - startDate?: Date; - endDate?: Date; - actualDate: Date; - }) => { - if (!val.startDate && !val.endDate) return true; - if (!val.startDate || !val.endDate) return false; - return val.actualDate >= val.startDate && val.actualDate <= val.endDate; - }; - z.object({ asdf: z.string() }, { required_error: "asdf" }); - - const schema = z - .object({ - startDate: z.date().optional(), - endDate: z.date().optional(), - actualDate: z.date(), - }) - .refine(dateRangeValidator); - - z.enum(["asdf"], { required_error: "error mesage" }); - console.log(schema.parse("100px")); // pass - console.log(schema.parse("100vw")); // fail -} -main(); - -const myErrorMap: z.ZodErrorMap = (val, ctx) => { - return { message: "whatever" }; -}; -z.setErrorMap(myErrorMap); +import { z } from "./src";