How to use generate-object-property - 7 common examples

To help you get started, we’ve selected a few generate-object-property 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 prometheusresearch-archive / react-forms / src / JSONSchema / compileValidator.js View on Github external
let checkRequired = function(req) {
        if (nullAsUndefined) {
          validate('if (%s == undefined) {', genobj(dataSym, req));
        } else {
          validate('if (%s === undefined) {', genobj(dataSym, req));
        }
        let reqSchema = genobj(nodeSym, 'properties') + ' ? ' + genobj(genobj(nodeSym, 'properties'), req) + ' : undefined'; // eslint-disable-line max-len
        error(messages.IS_REQUIRED, genobj(name, req), undefined, reqSchema);
        validate('missing++');
        validate('}');
      };
      validate('if ((%s)) {', type !== 'object' ? types.object(dataSym) : 'true');
github prometheusresearch-archive / react-forms / src / JSONSchema / compileValidator.js View on Github external
let checkRequired = function(req) {
        if (nullAsUndefined) {
          validate('if (%s == undefined) {', genobj(dataSym, req));
        } else {
          validate('if (%s === undefined) {', genobj(dataSym, req));
        }
        let reqSchema = genobj(nodeSym, 'properties') + ' ? ' + genobj(genobj(nodeSym, 'properties'), req) + ' : undefined'; // eslint-disable-line max-len
        error(messages.IS_REQUIRED, genobj(name, req), undefined, reqSchema);
        validate('missing++');
        validate('}');
      };
      validate('if ((%s)) {', type !== 'object' ? types.object(dataSym) : 'true');
github prometheusresearch-archive / react-forms / src / JSONSchema / compileValidator.js View on Github external
let checkRequired = function(req) {
        if (nullAsUndefined) {
          validate('if (%s == undefined) {', genobj(dataSym, req));
        } else {
          validate('if (%s === undefined) {', genobj(dataSym, req));
        }
        let reqSchema = genobj(nodeSym, 'properties') + ' ? ' + genobj(genobj(nodeSym, 'properties'), req) + ' : undefined'; // eslint-disable-line max-len
        error(messages.IS_REQUIRED, genobj(name, req), undefined, reqSchema);
        validate('missing++');
        validate('}');
      };
      validate('if ((%s)) {', type !== 'object' ? types.object(dataSym) : 'true');
github mafintosh / protocol-buffers / compile.js View on Github external
forEach(function (e, f) {
      var def = f.options && f.options.default
      var resolved = resolve(f.type, m.id, false)
      var vals = resolved && resolved.values

      if (vals) { // is enum
        if (f.repeated) {
          objectKeys.push(genobj.property(f.name) + ': []')
        } else {
          def = (def && vals[def]) ? vals[def].value : vals[Object.keys(vals)[0]].value
          objectKeys.push(genobj.property(f.name) + ': ' + parseInt(def || 0, 10))
        }
        return
      }

      objectKeys.push(genobj.property(f.name) + ': ' + defaultValue(f, def))
    })
github prometheusresearch-archive / react-forms / src / JSONSchema / compileValidator.js View on Github external
}

        let exists = function(k) {
          return genobj(dataSym, k) + ' !== undefined';
        };

        if (Array.isArray(deps)) {
          validate(
            'if (%s !== undefined && !(%s)) {',
            genobj(dataSym, key), deps.map(exists).join(' && ') || 'true'
          );
          error(messages.DEPENDENCIES_NOT_SET);
          validate('}');
        }
        if (typeof deps === 'object') {
          validate('if (%s !== undefined) {', genobj(dataSym, key));
          visit(name, dataSym, deps, reporter, filter);
          validate('}');
        }
      });
github prometheusresearch-archive / react-forms / src / JSONSchema / compileValidator.js View on Github external
Object.keys(properties).forEach(function(p) {
        visit(genobj(name, p), genobj(dataSym, p), properties[p], reporter, filter);
      });
    }
github prometheusresearch-archive / react-forms / src / JSONSchema / compileValidator.js View on Github external
let exists = function(k) {
          return genobj(dataSym, k) + ' !== undefined';
        };

generate-object-property

Generate safe JS code that can used to reference a object property

MIT
Latest version published 3 months ago

Package Health Score

72 / 100
Full package analysis

Popular generate-object-property functions