backbone.validation
backbone.validation copied to clipboard
It would be useful to accept `labels` values as functions
When using the label labelFormatter
, the value of each label can only be a string:
var Model = Backbone.Model.extend({
validation: {
someAttribute: {
required: true
}
},
labels: {
someAttribute: 'Custom label'
}
});
There are some cases were we may want to have a function executed when building the error message. One of those is having internationalised labels depending on a preference of the user.
This would look like:
var Model = Backbone.Model.extend({
validation: {
someAttribute: {
required: true
}
},
labels: {
someAttribute: function() {
return 'Dynamic custom label';
}
}
});
This looks so useful! Can someone submit this PR?