Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow objects & lists as @default values #111

Open
smoove opened this issue Jan 23, 2023 · 0 comments
Open

Allow objects & lists as @default values #111

smoove opened this issue Jan 23, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@smoove
Copy link

smoove commented Jan 23, 2023

Default values are currently limited to number | string | boolean;

Input

type Whatever = {
  /**
   * @default []
   */
  someField: string[];
  
  /**
   * @default {someProp: 'default value'}
   */
  someOtherField: {...};
};

Output

[...]
someField: z.array(z.string()).default('[]'),
someOtherField: z.object(...).default('{"someProp": "default value"}'),
[...]

Expected Output

[...]
someField: z.array(z.string()).default([]),
someOtherField: z.object(...).default({"someProp": "default value"}),
[...]
@tvillaren tvillaren added the enhancement New feature or request label Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants