import * as valita from '@badrap/valita';
import { skipAssertJSONValue } from "./config.js";
import { isJSONObject, isJSONValue } from "./json.js";
import * as v from "./valita.js";
const path = [];
export const jsonSchema = v
    .unknown()
    .chain(v => {
    if (skipAssertJSONValue) {
        return valita.ok(v);
    }
    const rv = isJSONValue(v, path)
        ? valita.ok(v)
        : valita.err({
            message: `Not a JSON value`,
            path: path.slice(),
        });
    path.length = 0;
    return rv;
});
export const jsonObjectSchema = v
    .unknown()
    .chain(v => {
    if (skipAssertJSONValue) {
        return valita.ok(v);
    }
    const rv = isJSONObject(v, path)
        ? valita.ok(v)
        : valita.err({
            message: `Not a JSON object`,
            path: path.slice(),
        });
    path.length = 0;
    return rv;
});
//# sourceMappingURL=json-schema.js.map