UNPKG

next-safe-action

Version:

Type safe and validated Server Actions in your Next.js project.

26 lines (25 loc) 561 B
// src/adapters/typebox.ts import { TypeCompiler } from "@sinclair/typebox/compiler"; var TypeboxAdapter = class { async validate(schema, data) { const result = TypeCompiler.Compile(schema); if (result.Check(data)) { return { success: true, data, }; } return { success: false, issues: [...result.Errors(data)].map(({ message, path }) => ({ message, path: path.split("/").slice(1), })), }; } }; function typeboxAdapter() { return new TypeboxAdapter(); } export { typeboxAdapter }; //# sourceMappingURL=typebox.mjs.map