Although I did not find a direct method of formatting a message using validator output (such as returning a custom value from the validator and receiving it as a parameter in the message formatter), I was able to use the element data storage in order to get the required effect.
I created a validator:
var ruleValidator = function(val, el){
var valid = true, error;
if(val == "a") {
valid = false;
error = 0;
} else if (val == "b") {
//...
}
if(!valid) {
//store data within element
$(el).data("errorId", error);
}
return valid;
};
which stores the error index in the element, and the error parser:
var parseError = function(val, el){
var errors = ["err a", "err b"];
var i = $(el).data("errorId");
return errors[i];
};
which returns the custom error message.
I then registered them:
$.validator.addMethod("customRule", ruleValidator, parseError);
And it did the trick. Here is a quick demo.
This could be against intended design, but if you know what you are doing and have a good reason for doing this, it appears to be possible.