in reply to How to make Params::Validate catch my typing errors

Another problem could be (in addition to the issues you have apparently encountered) that you're essentially assuming that things are ok as long as one of the options (like "callbacks", "type", etc.) is correct, instead of testing if any of them is wrong. In other words, a correct "type" option could potentially mask an incorrect "callback" option, because the existence of the former could set found = 1 in case both occur in the same spec...

Anyhow, something like this - right at the beginning of validate_one_param() - should work:

static char* valid_keys[] = { "callbacks", "can", "default", "depends", "isa", "optional", " +regex", "type" }; HE* he; hv_iterinit(spec); while (he = hv_iternext(spec)) { STRLEN len; char* key = HePV(he, len); int ok = 0; int j; for (j=0; j < sizeof(valid_keys)/sizeof(valid_keys[0]); j++) { if (strcmp(key, valid_keys[j]) == 0) { ok = 1; break; } } if (!ok) { SV* buffer = sv_2mortal(newSVpv("'",0)); sv_catpv(buffer, key); sv_catpv(buffer, "': unknown option error\n"); FAIL(buffer, options); } }

At least it does pass all the tests that come with the module. And with your typo-ed 'callback', it croaks with

$ ./841578.pl 1..4 'callback': unknown option error at ./841578.pl line 14 main::howareyoufeelingtoday('happy') called at ./841578.pl lin +e 18 # Looks like your test exited with 9 before it could output anything.

(Of course, you could also implement the strcmp loop as a hash lookup, if you like)