Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Validate/schema#9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ShMcK merged 3 commits intomasterfromvalidate/schema
May 31, 2020
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
NextNext commit
setup validator
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
  • Loading branch information
@ShMcK
ShMcK committedMay 31, 2020
commit8490cecd222cbe63e3f2cde8e52fd485d9b8ac26
23 changes: 13 additions & 10 deletionspackage-lock.json
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

2 changes: 2 additions & 0 deletionspackage.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,6 +19,7 @@
"author": "Argemiro Neto",
"license": "ISC",
"dependencies": {
"ajv": "^6.12.2",
"arg": "^4.1.3",
"esm": "^3.2.25",
"inquirer": "^7.1.0",
Expand All@@ -31,6 +32,7 @@
},
"devDependencies": {
"@babel/preset-typescript": "^7.10.1",
"@types/ajv": "^1.0.0",
"@types/inquirer": "^6.5.0",
"@types/jest": "^25.2.3",
"@types/js-yaml": "^3.12.4",
Expand Down
1 change: 0 additions & 1 deletionsrc/build.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
import * as yamlParser from "js-yaml";
import * as path from "path";
import * as _ from "lodash";
import * as fs from "fs";
Expand Down
23 changes: 23 additions & 0 deletionssrc/utils/validate.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
import * as T from "../../typings/tutorial";
import schema from "./schema";

// https://www.npmjs.com/package/ajv
// @ts-ignore ajv typings not working
import JsonSchema from "ajv";

export function validateSchema(json: T.Tutorial) {
// validate using https://json-schema.org/
const jsonSchema = new JsonSchema({ allErrors: true, verbose: true });
// support draft-07 of json schema
jsonSchema.addMetaSchema(require("ajv/lib/refs/json-schema-draft-07.json"));

const valid = jsonSchema.compile(schema, json);

if (!valid) {
// log errors
console.log(jsonSchema.errorsText());
throw new Error("Invalid schema. See log for details");
}

return true;
}

[8]ページ先頭

©2009-2025 Movatter.jp