How to use the ajv-merge-patch function in ajv-merge-patch

To help you get started, we’ve selected a few ajv-merge-patch examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mozilla / addons-linter / src / schema / validator.js View on Github external
manifestShortcutKey,
} from './formats';
import schemas from './imported';

const validator = ajv({
  allErrors: true,
  errorDataPath: 'property',
  jsonPointers: true,
  verbose: true,
  schemas,
  schemaId: 'auto',
});

validator.addMetaSchema(require('ajv/lib/refs/json-schema-draft-06.json'));

ajvMergePatch(validator);

validator.addFormat('versionString', isValidVersionString);
validator.addFormat('contentSecurityPolicy', () => true);
validator.addFormat('ignore', () => true);
validator.addFormat('manifestShortcutKey', manifestShortcutKey);

// URL formats. The format names don't mean what you'd think, see bug 1354342.
//
// url -> MUST be absolute URL
// relativeUrl -> CHOICE of absolute URL or relative URL (including protocol relative)
// strictRelativeUrl -> MUST be relative, but not protocol relative (path only)
validator.addFormat('url', isAbsoluteUrl);
validator.addFormat('relativeUrl', isAnyUrl);
// homepageUrl is the same as relativeUrl but Firefox will encode | characters.
validator.addFormat('homepageUrl', isAnyUrl);
validator.addFormat('strictRelativeUrl', isStrictRelativeUrl);

ajv-merge-patch

$merge and $patch keywords for Ajv JSON-Schema validator to extend schemas

MIT
Latest version published 3 years ago

Package Health Score

44 / 100
Full package analysis

Popular ajv-merge-patch functions