mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-16 11:37:58 +02:00
34 lines
914 B
JavaScript
34 lines
914 B
JavaScript
|
NzbDrone.Quality.QualityTypeModel = Backbone.Model.extend({
|
||
|
|
||
|
initialize: function () {
|
||
|
this.validators = {};
|
||
|
},
|
||
|
|
||
|
validateItem: function (key) {
|
||
|
return (this.validators[key]) ? this.validators[key](this.get(key)) : { isValid: true };
|
||
|
},
|
||
|
|
||
|
// TODO: Implement Backbone's standard validate() method instead.
|
||
|
validateAll: function () {
|
||
|
|
||
|
var messages = {};
|
||
|
|
||
|
for (var key in this.validators) {
|
||
|
if (this.validators.hasOwnProperty(key)) {
|
||
|
var check = this.validators[key](this.get(key));
|
||
|
if (check.isValid === false) {
|
||
|
messages[key] = check.message;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return _.size(messages) > 0 ? { isValid: false, messages: messages } : { isValid: true };
|
||
|
},
|
||
|
|
||
|
defaults: {
|
||
|
Id: null,
|
||
|
Name: '',
|
||
|
MaxSize: 100,
|
||
|
MinSize: 0
|
||
|
}
|
||
|
});
|