Copy
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "UserProfile",
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"email": {
"type": "string"
},
"username": {
"type": "string"
},
"phone": {
"type": "string"
},
"image": {
"type": "string"
},
"age": {
"type": "integer"
},
"address": {
"type": "object",
"properties": {
"address": {
"type": "string"
},
"city": {
"type": "string"
},
"state": {
"type": "string"
},
"stateCode": {
"type": "string"
},
"postalCode": {
"type": "string"
},
"country": {
"type": "string"
}
},
"required": [
"address",
"city",
"state",
"stateCode",
"postalCode",
"country"
],
"additionalProperties": false
},
"company": {
"type": "object",
"properties": {
"department": {
"type": "string"
},
"name": {
"type": "string"
},
"title": {
"type": "string"
}
},
"required": [
"department",
"name",
"title"
],
"additionalProperties": false
}
},
"required": [
"id",
"firstName",
"lastName",
"email",
"username",
"phone",
"image",
"age",
"address",
"company"
],
"additionalProperties": false
}
Copy
import { z } from 'zod';
export const UserProfileSchema = z.object({
id: z.number(),
firstName: z.string(),
lastName: z.string(),
email: z.string(),
username: z.string(),
phone: z.string(),
image: z.string(),
age: z.number(),
address: z.object({
address: z.string(),
city: z.string(),
state: z.string(),
stateCode: z.string(),
postalCode: z.string(),
country: z.string()
}),
company: z.object({
department: z.string(),
name: z.string(),
title: z.string()
})
});
export type UserProfile = z.infer<typeof UserProfileSchema>;