From 8e96c13a4fc22c2909cd0667d8c70c3b812655cd Mon Sep 17 00:00:00 2001 From: Trystian Date: Thu, 30 Aug 2018 15:02:00 +0200 Subject: [PATCH] develop: fixed some things --- dist/backbone-validation-amd.js | 11 ++++++----- dist/backbone-validation.js | 11 ++++++----- src/backbone-validation.js | 9 +++++---- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/dist/backbone-validation-amd.js b/dist/backbone-validation-amd.js index 8929b600..fd6e69a0 100644 --- a/dist/backbone-validation-amd.js +++ b/dist/backbone-validation-amd.js @@ -1,6 +1,6 @@ // Backbone.Validation v0.9.0 // -// Copyright (c) 2011-2013 Thomas Pedersen +// Copyright (c) 2011-2018 Thomas Pedersen // Distributed under MIT License // // Documentation and full license available at: @@ -215,15 +215,16 @@ // entire model is valid. Passing true will force a validation // of the model. isValid: function(option) { - var flattened = flatten(this.attributes); + var _this = this, + flattened = flatten(this.attributes); if(_.isString(option)){ return !validateAttr(this, option, flattened[option], _.extend({}, this.attributes)); } if(_.isArray(option)){ return _.reduce(option, function(memo, attr) { - return memo && !validateAttr(this, attr, flattened[attr], _.extend({}, this.attributes)); - }, true, this); + return memo && !validateAttr(_this, attr, flattened[attr], _.extend({}, _this.attributes)); + }, true); } if(option === true) { this.validate(); @@ -611,7 +612,7 @@ // Validates that the value has to be equal to one of the elements in // the specified array. Case sensitive matching oneOf: function(value, attr, values, model) { - if(!_.include(values, value)){ + if(!_.includes(values, value)){ return this.format(defaultMessages.oneOf, this.formatLabel(attr, model), values.join(', ')); } }, diff --git a/dist/backbone-validation.js b/dist/backbone-validation.js index 97033a55..ab717061 100644 --- a/dist/backbone-validation.js +++ b/dist/backbone-validation.js @@ -1,6 +1,6 @@ // Backbone.Validation v0.9.0 // -// Copyright (c) 2011-2013 Thomas Pedersen +// Copyright (c) 2011-2018 Thomas Pedersen // Distributed under MIT License // // Documentation and full license available at: @@ -208,15 +208,16 @@ Backbone.Validation = (function(_){ // entire model is valid. Passing true will force a validation // of the model. isValid: function(option) { - var flattened = flatten(this.attributes); + var _this = this, + flattened = flatten(this.attributes); if(_.isString(option)){ return !validateAttr(this, option, flattened[option], _.extend({}, this.attributes)); } if(_.isArray(option)){ return _.reduce(option, function(memo, attr) { - return memo && !validateAttr(this, attr, flattened[attr], _.extend({}, this.attributes)); - }, true, this); + return memo && !validateAttr(_this, attr, flattened[attr], _.extend({}, _this.attributes)); + }, true); } if(option === true) { this.validate(); @@ -604,7 +605,7 @@ Backbone.Validation = (function(_){ // Validates that the value has to be equal to one of the elements in // the specified array. Case sensitive matching oneOf: function(value, attr, values, model) { - if(!_.include(values, value)){ + if(!_.includes(values, value)){ return this.format(defaultMessages.oneOf, this.formatLabel(attr, model), values.join(', ')); } }, diff --git a/src/backbone-validation.js b/src/backbone-validation.js index 2cba0cd8..6068a2b2 100644 --- a/src/backbone-validation.js +++ b/src/backbone-validation.js @@ -201,15 +201,16 @@ Backbone.Validation = (function(_){ // entire model is valid. Passing true will force a validation // of the model. isValid: function(option) { - var flattened = flatten(this.attributes); + var _this = this, + flattened = flatten(this.attributes); if(_.isString(option)){ return !validateAttr(this, option, flattened[option], _.extend({}, this.attributes)); } if(_.isArray(option)){ return _.reduce(option, function(memo, attr) { - return memo && !validateAttr(this, attr, flattened[attr], _.extend({}, this.attributes)); - }, true, this); + return memo && !validateAttr(_this, attr, flattened[attr], _.extend({}, _this.attributes)); + }, true); } if(option === true) { this.validate(); @@ -597,7 +598,7 @@ Backbone.Validation = (function(_){ // Validates that the value has to be equal to one of the elements in // the specified array. Case sensitive matching oneOf: function(value, attr, values, model) { - if(!_.include(values, value)){ + if(!_.includes(values, value)){ return this.format(defaultMessages.oneOf, this.formatLabel(attr, model), values.join(', ')); } },