UNPKG

@palmares/schemas

Version:

This defines a default schema definition for validation of data, it abstract popular schema validation libraries like zod, yup, valibot and others"

37 lines (32 loc) 992 B
var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); // src/compile.ts import { getDefaultStd } from "@palmares/core"; // src/exceptions.ts var NoAdapterFoundError = class extends Error { static { __name(this, "NoAdapterFoundError"); } constructor() { super("No adapter found, please define an adapter using setDefaultAdapter() before using any schema."); } }; // src/conf.ts function getDefaultAdapter() { if (!globalThis.$PSchemasAdapter) throw new NoAdapterFoundError(); return globalThis.$PSchemasAdapter; } __name(getDefaultAdapter, "getDefaultAdapter"); // src/compile.ts async function compile(schemas) { const schemasAsEntries = Object.entries(schemas); const adapter = getDefaultAdapter(); const std = getDefaultStd(); for (const [keyName, schema] of schemasAsEntries) { console.log(await schema.compile(adapter)); } } __name(compile, "compile"); export { compile };