-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadhoc-test.js
More file actions
36 lines (31 loc) · 778 Bytes
/
adhoc-test.js
File metadata and controls
36 lines (31 loc) · 778 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const YAML = require('yaml');
const fs = require('fs');
const validateSchema = require('yaml-schema-validator');
const file = fs.readFileSync('./app-compose.yml', 'utf8');
const appYml = YAML.parse(file);
const versionCheck = (val) => val === 1;
const requiredSchema = {
version: { type: 'number', use: { versionCheck } },
clean: {
excludeDir: [
{
type: 'string',
},
],
excludeFile: [
{
type: 'string',
},
],
},
generate: [
{
description: { type: 'string' },
root: { type: 'boolean' },
templateUrl: { type: 'string', required: true },
},
],
};
const schemaErrors = validateSchema(appYml, { schema: requiredSchema });
console.log(schemaErrors);
console.log(JSON.stringify(appYml));