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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user