Created
July 25, 2019 18:13
-
-
Save MrDOS/9973a0d9ba22bd6799922c1b4ad39890 to your computer and use it in GitHub Desktop.
The Daily WTF: Break my Validation
This file contains 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 characters
modifyValidatorValue: function (fieldName, validatorKey, key, value) { | |
if (helper.isNullOrUndefined(fieldName) | |
|| helper.isNullOrUndefined(validatorKey) | |
|| helper.isNullOrUndefined(key) | |
|| helper.isNullOrUndefined(value)) { | |
return; | |
} | |
// Iterate over fields | |
var field; | |
for (var i in this.fields) { | |
if (!this.fields.hasOwnProperty(i)) { | |
continue; | |
} | |
var field = this.fields[i]; | |
if (field.name !== fieldName) { | |
continue; | |
} else { | |
break; | |
} | |
} | |
if (!field.hasOwnProperty('validators')) { | |
return; | |
} | |
// Iterate over validators | |
var validator; | |
for (var j in field.validators) { | |
if (!field.validators.hasOwnProperty(j)) { | |
continue; | |
} | |
var validator = field.validators[j]; | |
if (validator.key !== validatorKey) { | |
continue; | |
} else { | |
break; | |
} | |
} | |
if (validator.hasOwnProperty(key)) { | |
validator[key] = value; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment