-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Description
Problem
I want to pick deeply nested properties.
In the example below, I want to get the validation schema for the school name property, which is 2 levels deep from the initial "person" object. Using the method pick, I can extract properties that are 1 level deep and I can get the "school" object. However, I cannot go deeper and get the properties of the school object. Is there another way to achieve this?
Schema:
const person = z.object({
name: z.string(),
school: z.object({
id: z.number(),
name: z.string()
})
});Desired solution
const justSchoolName = person.deepPick({
school: {
name: true
}
});Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels