Skip to content

Commit

Permalink
fix(notion-api-zod-schema): formula schema
Browse files Browse the repository at this point in the history
  • Loading branch information
alanlu-zyl committed May 3, 2024
1 parent e1683dc commit 2d9da9c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/fast-pants-play.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@alanlu-dev/notion-api-zod-schema": patch
---

fix(notion-api-zod-schema): formula schema
19 changes: 15 additions & 4 deletions packages/notion-api-zod-schema/src/NotionDatabaseSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,21 @@ export type NotionButtonType = z.infer<typeof NotionButtonSchema>
// formula
export const NotionFormulaSchema = z.object({
type: z.literal('formula'),
formula: z.object({
type: z.literal('string'),
string: z.string().nullable(),
}),
formula: z.discriminatedUnion('type', [
z.object({
type: z.literal('string'),
string: z.string().nullable(),
}),
z.object({
type: z.literal('number'),
number: z.number().nullable(),
}),
z.object({
type: z.literal('boolean'),
boolean: z.boolean().nullable(),
}),
NotionDateSchema,
]),
})
export type NotionFormulaType = z.infer<typeof NotionFormulaSchema>

Expand Down

0 comments on commit 2d9da9c

Please sign in to comment.