bc39ffa265
- Introduce `@oh-my-pi/omptype` as a new ArkType-compatible schema validation package featuring a lazy JIT runtime, JSON Schema emission, and compatibility adapters. - Replace `arktype` across workspace packages and test utilities with `@oh-my-pi/omptype`. - Add benchmark suites, tests, and documentation for the new validation engine and adapters. - Update workspace build, test runner, and release configurations to include the new package.
22 lines
663 B
TypeScript
22 lines
663 B
TypeScript
import { expect } from "bun:test";
|
|
import { type as arkType, type Type } from "@oh-my-pi/omptype";
|
|
|
|
function formatIssues(error: unknown): string {
|
|
if (error instanceof Error) {
|
|
return error.message;
|
|
}
|
|
return String(error);
|
|
}
|
|
|
|
export function expectAcpStructure(schema: Type, value: unknown): void {
|
|
const result = schema(value);
|
|
const isValid = !(result instanceof arkType.errors);
|
|
expect(isValid, isValid ? undefined : formatIssues(result)).toBe(true);
|
|
}
|
|
|
|
export function expectAcpStructureRejects(schema: Type, value: unknown): void {
|
|
const result = schema(value);
|
|
const isValid = !(result instanceof arkType.errors);
|
|
expect(isValid).toBe(false);
|
|
}
|