Billy
Billy

Reputation: 15706

In Zend framework, where should I put the custom validator?

I put the class under
application\validate\PasswordConfirmation.php

And it doesn't work.

Error
Class 'Default_Validate_PasswordConfirmation' not found

still occurs.

Does anyone have this problem before?

Upvotes: 3

Views: 1765

Answers (3)

Billy
Billy

Reputation: 15706

Let me answer my own question:

I add the validator successfully according to this post: Where should My_Validate_PasswordConfirmation put in Zend framework?

Upvotes: 1

Macarse
Macarse

Reputation: 93123

I usually place them at /library/CV/Validate/

Example:

/library/CV/Validate/EmpresaNueva.php:
class CV_Validate_EmpresaNueva extends Zend_Validate_Abstract {
    //Validator code
}

Where library is the place where you have Zend.

Content of index.php @ /public:

$root = dirname(dirname(__FILE__));

set_include_path($root.'/application' . PATH_SEPARATOR
    .$root.'/library' . PATH_SEPARATOR
    . get_include_path()
);

Upvotes: 1

Kieran Hall
Kieran Hall

Reputation: 2627

For customer validators, you need to put them in a location that is on your include path. Also, you need to add your validator to make it available using Zend_Validate::addValidator().

See the documentation for more information.

Upvotes: 1

Related Questions