(json?: string)
| 1 | import { z } from "zod"; |
| 2 | |
| 3 | export function safeJsonParse(json?: string): unknown { |
| 4 | if (!json) { |
| 5 | return; |
| 6 | } |
| 7 | |
| 8 | try { |
| 9 | return JSON.parse(json); |
| 10 | } catch (e) { |
| 11 | return null; |
| 12 | } |
| 13 | } |
| 14 | |
| 15 | export function safeJsonZodParse<T>( |
| 16 | schema: z.Schema<T>, |
no test coverage detected
searching dependent graphs…