JSFiddle - React, Tailwind, and code Playground

HTML

<script src="http://code.jquery.com/jquery-1.9.0.js"></script>
<script src="http://dl.dropbox.com/u/16292713/js/backbone.js"></script>
<script src="http://dl.dropbox.com/u/16292713/js/underscore.js"></script>

JavaScript

var Vehicle = Backbone.Model.extend({
    color: 'green',
    validate: function (attrs) {
   		var validColors = ['white', 'red', 'blue', 'yellow'];
        var colorIsValid = function (attrs) {
            if (!attrs.color) return true;
            return _.contains(validColors, attrs.color);
        }
        if(!colorIsValid(attrs)) {
            return "color must be one of: " +validColors.join(",");
        }
    }
});

var car = new Vehicle();

car.on('error', function (model, error) {
	console.log(error);
});

console.log(car.get('color'));
car.set('color', 'muave', {validate: true});