n-time/backbone.validations — Issue #11: "in" does not validate properly
Author: donaldducky
Created: 2011-12-22 17:42:38+00:00
State: open

I have a model with validations like

```javascript
type:
in: ['a','b']
```

When I save with

```javascript
model.save({ type: 'a' })
```

The 'in' validator doesn't get passed `valueToSet` properly:

```javascript
"in" : function(whitelist, attributeName, model, valueToSet) {
console.log(whitelist, attributeName, model, valueToSet);
return _.include(whitelist, valueToSet) ? undefined : "in";
},
```

Gives the log output:
```javascript
["a", "b"]
"type"
d
undefined
```

`valueToSet` is undefined somewhere along the way.

My quick fix, for now:
```javascript
"in" : function(whitelist, attributeName, model, valueToSet) {
valueToSet = model.get(attributeName);
return _.include(whitelist, valueToSet) ? undefined : "in";
},
```