backbone.validation
backbone.validation copied to clipboard
Attribute "greater than"
Is an extension of the min attribute possible, which only allows greater?
Yes, you can use something like this.
_.extend(Backbone.Validation.validators, {
greaterThan : function (value, attr, minValue, model) {
var val = parseInt(value, 10);
if (_.isNaN(val) || val <= minValue) {
return this.format("{0} must be greater than {1}",
this.formatLabel(attr, model), minValue);
}
}
}