- 
        Couldn't load subscription status. 
- Fork 81
Open
Description
it's very difficult to validate certain properties without being able to refer to other object properties: e.g. comparing two dates, etc.
it would be pretty easy to create this functionality via "conform" attribute -- conform function could receive one extra parameter "object" which would reference the whole object with properties being validated.
so, when calling checkType, the "conform" constraint would take this form:
constrain('conform', value, function (a, e, object) { return e(a, object) });
instead of the current:
constrain('conform', value, function (a, e) { return e(a) });
and the "constrain" function would change from this:
function constrain(name, value, assert) {
  if (schema[name] !== undefined && !assert(value, schema[name])) {
    error(name, property, value, schema, errors);
  }
}
to this ('object' would exist in this context just like schema)
function constrain(name, value, assert) {
  if (schema[name] !== undefined && !assert(value, schema[name], object)) {
    error(name, property, value, schema, errors);
  }
}
consequently, the "conform" attribute would take this form:
{ conform: function (v,object) {
        if(object['some_other_property'] > v) return true;
        return false;
    }
}
Metadata
Metadata
Assignees
Labels
No labels