next-safe-action
Version:
Type safe and validated Server Actions in your Next.js project.
26 lines (25 loc) • 570 B
JavaScript
// src/adapters/valibot.ts
import { getDotPath, safeParseAsync } from "valibot";
var ValibotAdapter = class {
async validate(schema, data) {
const result = await safeParseAsync(schema, data);
if (result.success) {
return {
success: true,
data: result.output,
};
}
return {
success: false,
issues: result.issues.map((issue) => ({
message: issue.message,
path: getDotPath(issue)?.split("."),
})),
};
}
};
function valibotAdapter() {
return new ValibotAdapter();
}
export { valibotAdapter };
//# sourceMappingURL=valibot.mjs.map