How to use the JSV.JSV.typeOf function in jsv

To help you get started, we’ve selected a few jsv 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 eirikurn / contracts / lib / schema.js View on Github external
"validator": function(instance, schema, self, report, parent, parentSchema, name) {
    var newValue, filter = schema.getValueOfProperty("filter");

    if (filter) {
      try {
        newValue = filter(instance.getValue(), schema);
        instance._value = newValue;
        if (parent) {
          if (newValue !== undefined) {
            parent._value[name] = newValue;
          } else if (jsv.typeOf(parent._value) === "array") {
            parent._value.splice(name, name + 1);
          } else {
            delete parent._value[name];
          }
        }
      } catch(e) {
        console.log("Unexpected error while running filter", e);
      }
    }

    oldValidator.apply(this, arguments);
  }
});