The following code does not generate the correct Zod schema.
public function rules()
{
return [
'name' => 'required|string|max:255',
'positions.*.id' => 'required|exists:positions,id',
'positions.*.name' => 'required|string|max:255',
'delete_positions.*' => 'required|exists:positions,id',
'add_positions.*.name' => 'required|string|max:255',
];
}
The output will be like this.
export const UpdatePositionGroupRequest = z.object({
name: z.coerce.string().max(255).nonempty(),
positions: z.array(z.object({
id: z.coerce.string().nonempty(),
name: z.coerce.string().max(255).nonempty()
})),
delete_positions: z.object({
*: z.coerce.string().nonempty() // <- Wrong
}),
add_positions: z.array(z.object({
name: z.coerce.string().max(255).nonempty()
}))
});