-
-
Save barneycarroll/09d0a3c4f3682310b260 to your computer and use it in GitHub Desktop.
Revisions
-
barneycarroll revised this gist
Mar 30, 2015 . 1 changed file with 6 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,19 +17,17 @@ m.validator.prototype.clearErrors = function () { } m.validator.prototype.validate = function () { this.clearErrors() for( var key in this.validations ){ var validator = this.validations[key] var value = this.model[key]() var result = validator.bind(this.model)(value) if (result) { this.errors[key] = result } } return self } -
nijikokun revised this gist
Mar 30, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,7 +21,7 @@ m.validator.prototype.validate = function () { this.clearErrors() Object.keys(this.validations).forEach(function (key) { var validator = self.validations[key] var value = self.model[key]() var result = validator.bind(self.model)(value) -
nijikokun revised this gist
Mar 30, 2015 . 1 changed file with 30 additions and 32 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,36 +2,34 @@ m.validator = function (model, validations) { this.errors = {} this.validations = validations this.model = model } m.validator.prototype.hasErrors = function () { return Object.keys(this.errors).length } m.validator.prototype.hasError = function (prop) { return this.errors[prop] } m.validator.prototype.clearErrors = function () { this.errors = {} } m.validator.prototype.validate = function () { var self = this this.clearErrors() Object.keys(validations).forEach(function (key) { var validator = self.validations[key] var value = self.model[key]() var result = validator.bind(self.model)(value) if (result) { self.errors[key] = result } }) return self } -
nijikokun revised this gist
Mar 29, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -23,7 +23,7 @@ m.validator = function (model, validations) { Object.keys(validations).forEach(function (key) { var validator = self.validations[key] var value = self.model[key]() var result = validator.bind(self.model)(value) if (result) { self.errors[key] = result -
nijikokun revised this gist
Mar 29, 2015 . 1 changed file with 7 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,23 +1,25 @@ m.validator = function (model, validations) { this.errors = {} this.validations = validations this.model = model this.hasErrors = function () { return Object.keys(this.errors).length } this.hasError = function (prop) { return this.errors[prop] } this.clearErrors = function () { this.errors = {} } this.validate = function () { var self = this this.clearErrors() Object.keys(validations).forEach(function (key) { var validator = self.validations[key] var value = self.model[key]() -
nijikokun created this gist
Mar 29, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ m.validator = function (model, validations) { this.errors = {} this.validations = {} this.model = model this.hasErrors = function () { return Object.keys(this.errors).length } this.clearErrors = function () { this.errors = {} } this.hasError = function (prop) { return this.errors[prop] } this.validate = function () { var self = this Object.keys(validations).forEach(function (key) { var validator = self.validations[key] var value = self.model[key]() var result = validator.bind(self.model, value) if (result) { self.errors[key] = result } }) return self } return this }