forked from Codehagen/Badget
-
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.
Feat enhanced type safety for Real Estate form (Codehagen#178)
* Added realestate zod schema * Added error message from zod * Fixed typo in valitators package.json
- Loading branch information
1 parent
d36abec
commit 1062141
Showing
3 changed files
with
165 additions
and
54 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,25 @@ | ||
import { z } from "zod"; | ||
|
||
export const realEstateSchema = z.object({ | ||
address: z | ||
.string({ required_error: "Address is required" }) | ||
.min(5, { message: "Address must be at least 5 characters" }), | ||
city: z | ||
.string({ required_error: "City is required" }) | ||
.min(3, { message: "City must be at least 3 characters" }), | ||
state: z | ||
.string({ required_error: "State is required" }) | ||
.min(2, { message: "State must be at least 2 characters" }), | ||
postalCode: z | ||
.string({ required_error: "Postal Code is required" }) | ||
.min(5, { message: "Postal Code must be at least 5 characters" }), | ||
purchaseDate: z.date({ required_error: "Purchase date is required" }), | ||
purchaseValue: z | ||
.number({ required_error: "Purchase value is required" }) | ||
.min(1, { message: "Purchase value must be at least 1" }), | ||
currentValue: z | ||
.number({ required_error: "Current value is required" }) | ||
.min(1, { message: "Current value must be at least 1" }), | ||
}); | ||
|
||
export type RealEstate = z.infer<typeof realEstateSchema>; |