MCPcopy Index your code
hub / github.com/awesome-opencode/awesome-opencode / validateEntry

Function validateEntry

scripts/utils/validation.js:36–57  ·  view source on GitHub ↗

* Validate an entry against the schema * @param {object} data - Parsed YAML data * @param {string} filePath - File path for error messages * @returns {object} { valid: boolean, errors: array|null }

(data, filePath)

Source from the content-addressed store, hash-verified

34 * @returns {object} { valid: boolean, errors: array|null }
35 */
36function validateEntry(data, filePath) {
37 const validate = getValidator();
38
39 // Remove internal metadata fields before validation
40 const cleanData = { ...data };
41 delete cleanData._filePath;
42 delete cleanData._fileName;
43
44 const valid = validate(cleanData);
45
46 if (!valid) {
47 const errors = validate.errors.map(err => ({
48 path: err.instancePath || '/',
49 message: err.message,
50 keyword: err.keyword,
51 params: err.params
52 }));
53 return { valid: false, errors, filePath };
54 }
55
56 return { valid: true, errors: null, filePath };
57}
58
59/**
60 * Format validation errors for display

Callers 3

generateCategorySectionFunction · 0.85
validateFileFunction · 0.85
loadEntriesFunction · 0.85

Calls 1

getValidatorFunction · 0.85

Tested by

no test coverage detected