1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-21 23:47:58 +01:00

Better option validation messages for the more confusing validators.

This commit is contained in:
Kris Maglione
2010-09-28 17:06:46 -04:00
parent 50c1c568a2
commit c2c33b77fb
3 changed files with 18 additions and 5 deletions

View File

@@ -234,8 +234,13 @@ const Option = Class("Option", {
if (newValues == null)
return "Operator " + operator + " not supported for option type " + this.type;
if (!this.isValidValue(newValues))
return this.invalidArgument(str || this.joinValues(values), operator);
try {
if (!this.isValidValue(newValues))
return this.invalidArgument(str || this.joinValues(values), operator);
}
catch (e) {
return this.invalidArgument(str || this.joinValues(values), operator) + ": " + e.message;
}
this.setValues(newValues, scope);
return null;
@@ -551,6 +556,12 @@ const Option = Class("Option", {
}
},
validIf: function (test, error) {
if (test)
return true;
throw Error(error);
},
// TODO: Run this by default?
/**
* Validates the specified <b>values</b> against values generated by the