Skip to content

Commit

Permalink
feat: create Zod's default function for entity's booleans (#1773)
Browse files Browse the repository at this point in the history
Signed-off-by: Théo Frison <[email protected]>
Co-authored-by: ymc9 <[email protected]>
  • Loading branch information
Arkanii and ymc9 authored Oct 14, 2024
1 parent 178f697 commit 383b8fe
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/schema/src/plugins/zod/utils/schema-gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
isInvocationExpr,
isNumberLiteral,
isStringLiteral,
isBooleanLiteral
} from '@zenstackhq/sdk/ast';
import { upperCaseFirst } from 'upper-case-first';
import { name } from '..';
Expand Down Expand Up @@ -282,6 +283,8 @@ export function getFieldSchemaDefault(field: DataModelField) {
return JSON.stringify(arg.value.value);
} else if (isNumberLiteral(arg.value)) {
return arg.value.value;
} else if (isBooleanLiteral(arg.value)) {
return arg.value.value;
} else if (
isInvocationExpr(arg.value) &&
isFromStdlib(arg.value.function.ref!) &&
Expand Down

0 comments on commit 383b8fe

Please sign in to comment.