How to use json-pointer - 10 common examples

To help you get started, we’ve selected a few json-pointer 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 cyber-crafts / validate / lib / BaseTypeValidator.js View on Github external
BaseTypeValidator.prototype.validate = function (obj, context, path) {
        if (path === void 0) { path = ''; }
        obj = cloneDeep(obj);
        var validatorPromises = [];
        // if the object under validation does not exist return default result
        if (!json_pointer_1.has(obj, path))
            return validatorPromises;
        var targetValue = json_pointer_1.get(obj, path);
        // loops over validators and build the validation result
        Object.values(this.validationRules).forEach(function (validationRule) {
            validatorPromises.push(validationRule(targetValue, obj, path, context));
        });
        return validatorPromises;
    };
    return BaseTypeValidator;
github cyber-crafts / validate / src / typeValidators / ArrayValidator / index.ts View on Github external
validate (value: any, context: Context, path: string = ''): Promise[] {
    value = cloneDeep(value)

    let results = super.validate(value, context, path)

    if (has(value, path)) {
      // validating each entry
      results = results.concat(this.allItemsValidator.validate(value, context, path))
    }

    this.singleItemValidators.forEach(validator => {
      results = results.concat(validator.validate(value, path, context))
    })

    return results
  }
github FabricLabs / fabric / types / service.js View on Github external
async _GET (path) {
    let result = null;

    if (path === '/') return this.state;

    try {
      result = pointer.get(this.state, path);
    } catch (E) {
      this.error(`Could not _GET() ${path}:`, E);
    }

    return result;
  }
github cyber-crafts / validate / src / typeValidators / ObjectValidator.ts View on Github external
Object.keys(this.keyValidators).forEach(propertyName => {
      const typeValidator = this.keyValidators[ propertyName ]
      const propertyPath = [ path, propertyName ].join('/')
      if (has(obj, propertyPath) && get(obj, propertyPath) !== null) {
        propertiesResults = propertiesResults.concat(typeValidator.validate(obj, context, propertyPath))
      }
    })
github cyber-crafts / validate / src / typeValidators / DateValidator.ts View on Github external
validate (obj: any, context: Context, path: string = ''): Promise[] {
    obj = cloneDeep(obj)

    if (path !== '') {
      set(obj, path, this.parse(get(obj, path)))
      return super.validate(obj, context, path)
    } else {
      return super.validate(this.parse(obj), context, path)
    }
  }
}
github cartant / firebase-nightlight / source / json.ts View on Github external
export function get(entity: any, path: string): any {

    return jsonPointer.get(entity, path);
}
github cyber-crafts / validate / lib / typeValidators / ObjectValidator.js View on Github external
this.requiredProps.forEach(function (property) {
            if (!json_pointer_1.has(obj, path + "/" + property) || json_pointer_1.get(obj, path + "/" + property) === null) {
                context.addError('object.requires', path, { property: property });
            }
        });
        var superResult = _super.prototype.validate.call(this, obj, context, path);
github cyber-crafts / validate / src / rules / string.ts View on Github external
confirmed: () => (value: string, obj: any, path: string): boolean => {
    const confirmPath = `${path}_confirmation`
    return (has(obj, path) && has(obj, confirmPath) && get(obj, path) === get(obj, confirmPath))
  },
}
github cyber-crafts / validate / src / typeValidators / ObjectValidator.ts View on Github external
this.requiredProps.forEach(property => {
      if (!has(obj, `${path}/${property}`) || get(obj, `${path}/${property}`) === null) {
        context.addError('object.requires', path, { property })
      }
    })
github nick121212 / fx-schema-form / packages / fx-schema-form-antd / libs / components / select.js View on Github external
exports.getData = function (state, props) {
    var schemaKey = props.schemaKey, mergeSchema = props.mergeSchema;
    var _a = mergeSchema.keys, keys = _a === void 0 ? [] : _a;
    var _b = state[props.schemaKey].data, data = _b === void 0 ? {} : _b;
    return jpp.has(data, jpp.compile(keys)) ? jpp.get(data, jpp.compile(keys)) : undefined;
};
/**

json-pointer

Some utilities for JSON pointers described by RFC 6901

MIT
Latest version published 3 years ago

Package Health Score

74 / 100
Full package analysis

Popular json-pointer functions

Similar packages