From 5cec1871ac21627608af6c07585d5e50ff30f281 Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Sat, 18 Feb 2023 14:18:17 +0100 Subject: [PATCH] Add documentation for the param parameter of z.custom --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 065fca695..347a76baa 100644 --- a/README.md +++ b/README.md @@ -1714,6 +1714,12 @@ If you don't provide a validation function, Zod will allow any value. This can b z.custom<{ arg: string }>(); // performs no validation ``` +You can customize the error message and other options by passing a second argument. This parameter works the same way as the params parameter of [`.refine`](#refine). + +```ts +z.custom<...>((val) => ..., "custom error message"); +``` + ## Schema methods All Zod schemas contain certain methods.