feat: add validation to widget edit modal inputs (#879)
* feat: add validation to widget edit modal inputs * chore: remove unused console.log statements
This commit is contained in:
@@ -14,9 +14,18 @@ const searchCityInput = z.object({
|
||||
query: z.string(),
|
||||
});
|
||||
|
||||
const searchCityOutput = z.object({
|
||||
results: z.array(citySchema),
|
||||
});
|
||||
const searchCityOutput = z
|
||||
.object({
|
||||
results: z.array(citySchema),
|
||||
})
|
||||
.or(
|
||||
z
|
||||
.object({
|
||||
generationtime_ms: z.number(),
|
||||
})
|
||||
.refine((data) => Object.keys(data).length === 1, { message: "Invalid response" })
|
||||
.transform(() => ({ results: [] })), // We fallback to empty array if no results
|
||||
);
|
||||
|
||||
export const locationSchemas = {
|
||||
searchCity: {
|
||||
|
||||
Reference in New Issue
Block a user