Skip to content

Commit

Permalink
fix: allow custom validations without parsers
Browse files Browse the repository at this point in the history
  • Loading branch information
cafadev committed Jun 11, 2024
1 parent 4f6419a commit ce5f3c2
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/plugin-rule-parsers/src/zod.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import type { ZodAny } from 'zod/lib/types'

export function zodSafeParser(raw: { value: unknown; rule: ZodAny }) {
if (typeof raw === 'string' || typeof raw === 'boolean')
return raw

const { value, rule } = raw
const result = rule.safeParse(value)

Expand Down

0 comments on commit ce5f3c2

Please sign in to comment.