-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5dd30f8
commit 6d8631f
Showing
9 changed files
with
186 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import z from 'zod'; | ||
|
||
const petsSchema = z.enum(['dog', 'cat', 'hamster', 'parrot', 'spider', 'goldfish']); | ||
const monsterSchema = z.enum(['kraken', 'sasquatch', 'mothman']); | ||
const fruits = z.enum(['apple', 'banana', 'kiwi']); | ||
|
||
export const schema = z.object({ | ||
admin: z.boolean().refine(val => val === true, { | ||
message: 'Please read and accept the terms and conditions' | ||
}), | ||
birthday: z.string().optional(), | ||
givenName: z.string().min(1), | ||
surname: z.string().min(1), | ||
contact: z.object({ | ||
tel: z.string(), | ||
email: z | ||
.object({ | ||
email: z.string().email(), | ||
confirmEmail: z.string().email() | ||
}) | ||
.superRefine(({ email, confirmEmail }, context) => { | ||
if (email !== confirmEmail) { | ||
context.addIssue({ | ||
code: z.ZodIssueCode.custom, | ||
message: 'E-Mail does not match', | ||
path: ['confirmEmail'] | ||
}); | ||
} | ||
}) | ||
}), | ||
amount: z.bigint(), | ||
range: z.number(), | ||
pet: petsSchema, | ||
fruits: z.array(fruits), | ||
description: z.string(), | ||
monster: z.object({ | ||
value: monsterSchema | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.