How to use the ajv-keywords.get function in ajv-keywords

To help you get started, we’ve selected a few ajv-keywords 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 ArkEcosystem / core / packages / crypto / src / validation / keywords.ts View on Github external
const bignumber = (ajv: Ajv) => {
    const instanceOf = ajvKeywords.get("instanceof").definition;
    instanceOf.CONSTRUCTORS.BigNumber = BigNumber;

    ajv.addKeyword("bignumber", {
        compile(schema) {
            return (data, dataPath, parentObject: any, property) => {
                const minimum = typeof schema.minimum !== "undefined" ? schema.minimum : 0;
                const maximum = typeof schema.maximum !== "undefined" ? schema.maximum : "9223372036854775807"; // 8 byte maximum

                const bignum = BigNumber.make(data);

                if (!bignum.isInteger()) {
                    return false;
                }

                let bypassGenesis: boolean = false;
                if (schema.bypassGenesis) {
github frctl / fractal / packages / internals / support / src / validator.js View on Github external
constructor(...args) {
    super(...args);
    ajvKeywords(this, ['instanceof', 'typeof', 'regexp']);
    const definition = require('ajv-keywords').get('instanceof').definition;
    definition.CONSTRUCTORS.File = require('./entities/file');
    definition.CONSTRUCTORS.Variant = require('./entities/variant');
    definition.CONSTRUCTORS.Component = require('./entities/component');
    definition.CONSTRUCTORS.Entity = require('./entities/entity');
  }
github frctl / fractal / packages / lib / support / src / validator.js View on Github external
constructor(...args) {
    super(...args);
    ajvKeywords(this, ['instanceof', 'typeof', 'regexp']);
    const definition = require('ajv-keywords').get('instanceof').definition;
    definition.CONSTRUCTORS.File = require('./entities/file');
    definition.CONSTRUCTORS.Entity = require('./entities/entity');
    definition.CONSTRUCTORS.Variant = require('./entities/variant');
    definition.CONSTRUCTORS.Template = require('./entities/template');
    definition.CONSTRUCTORS.Scenario = require('./entities/scenario');
    definition.CONSTRUCTORS.Component = require('./entities/component');
    definition.CONSTRUCTORS.Collection = require('./collections/collection');
    definition.CONSTRUCTORS.FileCollection = require('./collections/file-collection');
    definition.CONSTRUCTORS.TemplateCollection = require('./collections/template-collection');
    definition.CONSTRUCTORS.EntityCollection = require('./collections/entity-collection');
    definition.CONSTRUCTORS.VariantCollection = require('./collections/variant-collection');
    definition.CONSTRUCTORS.ComponentCollection = require('./collections/component-collection');
  }

ajv-keywords

Additional JSON-Schema keywords for Ajv JSON validator

MIT
Latest version published 3 years ago

Package Health Score

73 / 100
Full package analysis