Zend Validator location

1.6k views Asked by At

Do I need to save my custom Zend Validator location to "Zend/Validate"? I'd rather create a folder for all my custom validation scripts, but cannot find anything in the Zend documentation other than changing the namespace.

Here is my error message.

"Plugin by name 'UserNameValidate' was not found in the registry; used paths: Zend_Validate_: Zend/Validate/"

I'd like to tell it to search additional paths.

3

There are 3 answers

0
Martin Konecny On BEST ANSWER

I was able to solve my problem using

addElementPrefixPath('Application_Validate',
                                    '../application/validate',
                                    'validate');
2
Cobby On

Did you check the API docs? Zend_Validate has an addDefaultNamespaces method...

public static function addDefaultNamespaces($namespace){
0
Marcin On

I usually keep my custom validators (e.g. My_Validate_Age) in APPLICATION_PATH/validators named, e.g. . In this case the php file would be: APPLICATION_PATH/validators/Age.php. With this setup I need to add the validators path to the Zend_Autoloader. For this purpose in the Bootstrap.php I have:

 protected function _initAutoload() {
    $autoLoader = Zend_Loader_Autoloader::getInstance();

    $resourceLoader = new Zend_Loader_Autoloader_Resource(array(
                'basePath' => APPLICATION_PATH,
                'namespace' => '',
            ));

    $resourceLoader->addResourceType('validate', 'validators/', 'My_Validate_');

    $autoLoader->pushAutoloader($resourceLoader);

}

Hope this will be of help to you.