aldeed/meteor-simple-schema — pull request #67 by gdhuse (2014-02-18 21:25:29+00:00)
Title: Pass the local object context to valueIsAllowed and custom validators to...

I needed to use custom validation with nested schemas, but the obj passed into valueIsAllowed() does not seem to contain enough context to do this. For example:

```
A = new SimpleSchema({
a_first: {
type: String,
valueIsAllowed: function(val, doc, op) {
// If I want to validate a_first against a_second I need to know how to find a_second in doc,
// but I can't tell whether I'm validating b_first.a_first or b_second.a_first here
}
},
a_second: { type: String }
});
B = new SimpleSchema({
b_first: { type: A },
b_second: { type: A }
})
```

My solution was to add a new argument referencing the object containing the key being validated.
```
valueIsAllowed: function(val, doc, op, localObject) {
// Can reference localObject.a_first or localObject.a_second
}
```