Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

How do i write zod schema if my data return triple inside object like example below

$
0
0
{

"2022-06-01": {"09:00am": {"time_table_id": 1,"job_id": 4,"start_working_time": "09:00am","end_working_time": "09:00pm","work_duration": "12:00:00","merchant_name": "Brands Outlet @ The Starling","address2": "Jalan SS 21/37, Damansara Utama","job_name": "Pro hero","job_application_status": "Hired"}},and this is my schema but the zod error come out.

      const apiScheme = z.object({     Date: z.object({        Time: z.object({        date: z.string(),        time_table_id: z.number().nullable(),            job_id: z.number(),            start_working_time: z.string(),            end_working_time: z.string(),       //       work_duration: z.string(),       //       merchant_name: z.string(),       //       address2: z.string(),            job_name: z.string(),            job_application_status: z.string(),     })  })

})

  const data = useMemo(() => {     if (responseData) {        const parseData = apiScheme.parse(responseData);        if (parseData) {           return parseData;        }     }     return null;  }, [responseData]);

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>