Files
Peter Steinberger e04ee09856 refactor: extract @clawdhub/schema package
- Move ArkType schemas into packages/schema

- Wire app/convex/cli imports to workspace dep

- Add workspaces + update lint/coverage

- Build schema dist (tracked)
2026-01-04 03:49:57 +01:00

26 lines
874 B
JavaScript

import { ArkErrors } from 'arktype';
export function parseArk(schema, data, label) {
const result = schema(data);
if (result instanceof ArkErrors) {
throw new Error(`${label}: ${formatArkErrors(result)}`);
}
return result;
}
export function formatArkErrors(errors) {
const parts = [];
for (const error of errors) {
if (parts.length >= 3)
break;
const path = Array.isArray(error.path) ? error.path.join('.') : '';
const location = path ? `${path}: ` : '';
const description = typeof error.description === 'string'
? error.description
: 'invalid value';
parts.push(`${location}${description}`);
}
if (errors.count > parts.length) {
parts.push(`+${errors.count - parts.length} more`);
}
return parts.join('; ');
}
//# sourceMappingURL=ark.js.map