Your question is very badly asked. So I will not dig into the logic of it.Sorry Here is a very simple example of how you can create a Custom Validation Class.
The most important thing you need to remember is two methods.
isValid()
: Returns either true or false through a logic
getMessages()
: Returns errors messages in case of invalid.
Here is a basic example of comparing whether a user is admin or not.
class CustomValidate_UserAdmin extends Zend_Validate_Abstract
{
$admin = "username"; //I am using a static value this time
protected $_messageTemplates = array(
self::FLOAT => "'%value%' is not an admin"
);
public function isValid($value)
{
$this->_setValue($value);
if($this -> admin == $value) {
return true;
}
}
}
Now use it
$element->addValidator(new CustomValidate_UserAdmin('username'));
This is a very simple example to understand. You can replace it with your logic with a lot of ease I think.
Updates
Add validation like this…
$element->addValidator(new CustomValidate_Hash('file/location', $hashvaluettocompare));
Now in your validation class
function isValid($location, $value) {
if(hash_file("md5", $location)==$value) return true;
}