MCPcopy Create free account
hub / github.com/StackExchange/Survey / validateFiles

Function validateFiles

packages/survey/scripts/validate-schema.ts:43–63  ·  view source on GitHub ↗
(schemaFile: string, files: string[])

Source from the content-addressed store, hash-verified

41 })
42 .join('; ')
43}
44
45function validateFiles(schemaFile: string, files: string[]): void {
46 const ajv = new Ajv({ allErrors: true, strict: false })
47 const validate = ajv.compile(readJson(schemaFile) as AnySchema)
48 let errors = 0
49
50 for (const file of files) {
51 const data = readYaml(file)
52 if (validate(data)) {
53 console.log(`${path.relative(process.cwd(), file)} valid`)
54 continue
55 }
56
57 errors += 1
58 console.error(`${path.relative(process.cwd(), file)} invalid`)
59 console.error(formatErrors(validate.errors ?? []))
60 }
61
62 if (errors > 0) {
63 process.exitCode = 1
64 }
65}
66

Callers 1

validate-schema.tsFile · 0.85

Calls 3

readJsonFunction · 0.85
readYamlFunction · 0.85
formatErrorsFunction · 0.85

Tested by

no test coverage detected