Skip to content

Instantly share code, notes, and snippets.

@Lily418
Created September 9, 2019 15:58
Show Gist options
  • Save Lily418/0fb96b6dd4ae87885f0c788b070383ac to your computer and use it in GitHub Desktop.
Save Lily418/0fb96b6dd4ae87885f0c788b070383ac to your computer and use it in GitHub Desktop.
const Ajv = require("ajv");
const pack = require("ajv-pack");
const ajv = new Ajv({
sourceCode: true,
schemaId: "auto",
allErrors: true,
jsonPointers: true,
errorDataPath: "property",
verbose: true
});
const drugSchema = require("schema.json");
const fs = require("fs");
const validate = ajv.compile(drugSchema);
const moduleCode = pack(ajv, validate);
fs.writeFileSync("./validate_schema.js", moduleCode);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment