Skip to content

Commit

Permalink
Update ci
Browse files Browse the repository at this point in the history
  • Loading branch information
Colin McDonnell committed Dec 12, 2022
1 parent 6e6efc2 commit f19c0f2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Expand Up @@ -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
Expand Down
33 changes: 1 addition & 32 deletions 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";

0 comments on commit f19c0f2

Please sign in to comment.