near-protocol-rewards
Version:
A transparent, metric-based rewards system for NEAR projects
43 lines (42 loc) • 1.2 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateWithSchema = void 0;
const zod_1 = require("zod");
const validateWithSchema = (schema, data) => {
try {
schema.parse(data);
return {
isValid: true,
errors: [],
warnings: [],
timestamp: Date.now(),
metadata: {
source: "github",
validationType: "data"
}
};
}
catch (error) {
if (error instanceof zod_1.z.ZodError) {
return {
isValid: false,
errors: error.errors.map((err) => ({
code: "VALIDATION_ERROR",
message: err.message,
context: {
path: err.path,
code: err.code,
},
})),
warnings: [],
timestamp: Date.now(),
metadata: {
source: "github",
validationType: "data"
}
};
}
throw error;
}
};
exports.validateWithSchema = validateWithSchema;