daily-co / daily-js

https://docs.daily.co/reference/daily-js
BSD 2-Clause "Simplified" License
103 stars 33 forks source link

[FEATURE-REQUEST] Built-in Zod validator for Daily API response #212

Closed ahkhanjani closed 9 months ago

ahkhanjani commented 1 year ago

Feature request

Hi there. It would be an amazing DX improvement to have a Zod schema out of the box to make sure the response we're getting matches our expectations and also get types in TypeScript. This is everything needed to implement it:

// import { z } from 'zod';

export const DailyResponseSchema = z.object({
  id: z.string(),
  name: z.string(),
  api_created: z.boolean(),
  privacy: z.enum(['public', 'private']),
  url: z.string().url(),
  created_at: z.string().datetime(),
  config: z.object({
    exp: z.number().int(),
    // ...
  }),
});

And adding Zod as an optional dependency in package.json.

Why you need this

Thank you