@ar.io/sdk
Version:
[](https://codecov.io/gh/ar-io/ar-io-sdk)
13 lines (12 loc) • 370 B
JavaScript
/**
* @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;
}