"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateJsonAndAssert = void 0;
const json_schema_1 = require("json-schema");
/*
  uses schema to validate a json object and if valid, returns it with the type asserted

  returns a tuple of [value, errors].
  If errors is null, then value will be a valid value with type T
  otherwise errors will be an array and value will be null
*/
function validateJsonAndAssert(json, schema) {
    if (!json || typeof json !== "object") {
        return [null, [{ message: "Could not parse json" }]];
    }
    const validation = (0, json_schema_1.validate)(json, schema);
    return validation.valid ? [json, null] : [null, validation.errors];
}
exports.validateJsonAndAssert = validateJsonAndAssert;

//# sourceMappingURL=../maps/jsonschema/SchemaValidation.js.map
