Here I see two options.
use atomic (logical) validators and separate error messages from the validator itself
if(!is_valid_email(blah)) print "invalid email";
use validator objects with boolean test () and string error () functions:
$v = new SomeValidator; if(!$v->test(blah)) echo $v->error();
in a quick and dirty application you can also consider returning an empty value if everything is ok
$err = validate_email(blah); if(empty($err)) ok else print $err;
source share