UNPKG

@ar.io/sdk

Version:

[![codecov](https://codecov.io/gh/ar-io/ar-io-sdk/graph/badge.svg?token=7dXKcT7dJy)](https://codecov.io/gh/ar-io/ar-io-sdk)

13 lines (12 loc) 370 B
/** * @param schema - zod schema * @param v - value to parse * @throws {z.SafeParseError<any>} - if the value fails to parse */ export function parseSchemaResult(schema, v) { const schemaResult = schema.safeParse(v); if (!schemaResult.success) { throw new Error(JSON.stringify(schemaResult.error.format(), null, 2)); } return schemaResult; }