-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: config zod schema validation (#121)
- Loading branch information
1 parent
7fb4a16
commit cd9a87e
Showing
6 changed files
with
64 additions
and
12 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,8 @@ | ||
import { z } from 'zod'; | ||
|
||
export const zod_required_string = ({ field_name }: { field_name: string }) => { | ||
return z | ||
.string() | ||
.min(1, { message: `${field_name} is required` }) | ||
.trim(); | ||
}; |
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,13 @@ | ||
import { zod_required_string } from '$lib/utils/zod'; | ||
import { z } from 'zod'; | ||
|
||
export const auth_schema = z.object({ | ||
email: zod_required_string({ field_name: 'Email' }).email({ | ||
message: 'Email is invalid' | ||
}), | ||
password: zod_required_string({ field_name: 'Password' }).min(8, { | ||
message: 'Password must contain atleast 8 chararcters' | ||
}) | ||
}); | ||
|
||
export type AuthSchema = z.infer<typeof auth_schema>; |
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