Skip to content
This repository has been archived by the owner on Nov 10, 2018. It is now read-only.

Commit

Permalink
cleaning up first part of validateInput
Browse files Browse the repository at this point in the history
  • Loading branch information
3n committed Mar 29, 2011
1 parent 0641102 commit 5ff0f99
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions Source/ValidateSimple.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,26 +161,25 @@ var ValidateSimple = new Class({
this.changeState('touched');
},

validateInput: function(input){
if (!this.active || input == undefined || input.retrieve('validate-simple-locked'))
return this;

if (input.get('tag') == 'option') return this.validateInput(input.getParent());

var validatorTypes = input.get(this.options.attributeForType),
validators = [];

_getValidatorTypesForInput: function(input){
var validatorTypes = input.get(this.options.attributeForType);
if (this.options.attributeForType == 'class'){
var mtch = validatorTypes.match(/validate\-[\w-]+/g);
validatorTypes = (mtch && mtch.length > 0) ? mtch : ['text'];
}
validatorTypes = $A(validatorTypes);

input.store('validate-simple-is-valid', true);
return $A(validatorTypes).map(function(vt){ return vt.replace('validate-',''); });
},

validateInput: function(input){
if (!this.active || input == undefined || input.retrieve('validate-simple-locked'))
return this;
else if (input.get('tag') == 'option')
return this.validateInput(input.getParent());

validatorTypes.each(function(validatorType){
var validatorType = validatorType.replace('validate-',''),
validator = ValidateSimple.Validators[validatorType],
input.store('validate-simple-is-valid', true);

this._getValidatorTypesForInput(input).each(function(validatorType){
var validator = ValidateSimple.Validators[validatorType],
testResult = validator.test(input);

if (testResult){
Expand Down

0 comments on commit 5ff0f99

Please sign in to comment.