« Return to Thread: Where to put my custom validators?

Re: Where to put my custom validators?

by Nicolas GREVET :: Rate this Message:

Reply to Author | View in Thread

You can also add this to your form element or a parent class:
    $this->addElementPrefixPath('MyPrefix_Validate_',
'MyPrefix/Validate/', 'validate');
If you don't want to add an autoloader for it.

Regards,
-- Nicolas



dmitrybelyakov a écrit :

>
> Mike Willbanks-3 wrote:
>  
>> Typically what I have done with validators in the past is create another
>> directory in the library folder (especially if I know I am going to use it
>> again).
>>
>> What I end up having is something like: library/MyCodeBase/Validators/*
>> and add them into the autoloader.  You could essentially do this from
>> within the module directory or even create a new directory under your file
>> system.
>>
>> You might also want to peak a bit more into the documentation on writing
>> the custom validators:
>> http://framework.zend.com/manual/en/zend.validate.writing_validators.html
>>
>> Regards,
>> Mike
>>
>>    
>
>
> Hi Mike,
>
> Thanks for your reply. The reference guide was quite clear on how to write
> validators but a bit unclear on where to put them. My concern was how to do
> it properly in the MVC layout to autoload per-module, but now i see that
> default module autoloader implementation does not search for validators as
> it does for forms, models or apis (what's that by the way?) so you need to
> setup the autoloading for validators yourself.
>
> Just was unsure if i did it the right way. Now it's completely clear.
>
> Good luck.
> Dmitry.
>
>  

 « Return to Thread: Where to put my custom validators?