Here's my strategy for dealing with validation code. I suppose by 'validation library', you mean those which just make sure an email is an email, telephone numbers are numerical, and are not business rules in nature.
The idea is to have each business rule code as a functor - if it is PHP, you can get by just using a string to define the function; for other languages, you may have to use the strategy pattern. Define an interface for the functor (not necessary for PHP) and dump it into an array.
Run through the array which will return success, error and an error-code to a buffer. At the end, examine the error buffer and determine which validation has failed. Use it to customise the view.
Here's an example
$checkUniqueUserName = new CheckUniqueUserName();
$checkEmailNotUsed = new EmailNotUsed();
$validator = array();
$validator[$checkUniqueUserName->name()] = $checkUniqueUserName;
$validator[$checkEmailNotUsed->name()] = $checkEmailNotUsed;
$results = array();
foreach ($validator as $v)
{
$result[$v->getValidatorName()] = $v->execute($userInfo);
}
class CheckUniqueUserName()
{
public function execute($userInfo)
{
// SQL blah blah blah
if ($bNameUnique)
return array ('success' => 1)
else
return array ('success' => 0, 'error' => "$name is in used", 'error_code' => 'duplicate_name);
}
}
At the end, you will have a results array, each filled with a validation process, and you know which has failed, and which has not. This can then be passed to the client-side for further processing, like highlighting the failed fields. The error_code an be used to look up the proper error message and formatting applied to it.
I am not really sure about what you mean by call-backs though.