Skip to content

Instantly share code, notes, and snippets.

@MrDOS
Created July 25, 2019 18:13
Show Gist options
  • Save MrDOS/9973a0d9ba22bd6799922c1b4ad39890 to your computer and use it in GitHub Desktop.
Save MrDOS/9973a0d9ba22bd6799922c1b4ad39890 to your computer and use it in GitHub Desktop.
The Daily WTF: Break my Validation
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