79188441

Date: 2024-11-14 11:02:03
Score: 1
Natty:
Report link

Easiest way I could do that with zod was,

enum Colour {
    red: 'Red',
    blue: 'Blue',
}

const isValidColour: bool = z.nativeEnum(Colour).safeParse("Red").success; // true

const isValidColour: bool = z.nativeEnum(Colour).safeParse("Pink").success; // false
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Jay Patel