Skip to content

Latest commit

 

History

History
10 lines (7 loc) · 400 Bytes

prefer-zod-default.md

File metadata and controls

10 lines (7 loc) · 400 Bytes

Prefer .default() over default in .openapi() (prefer-zod-default)

Provides an error when default is used in .openapi() option. ZodDefault .default() should be used instead.

A simple example

const NameSchema = z.string().openapi({ example: 'Fred', default: 'Fred' }); // ❌ error
const NameSchema = z.string().default('Fred').openapi({ example: 'Fred' }); // ✅ correct