Where to put my custom validators?

View: New views
4 Messages — Rating Filter:   Alert me  

Where to put my custom validators?

by dmitrybelyakov :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello everybody,

I just wonder if there's a default or recommended location for custom validator classes that go along with my module's forms. I am having trouble getting it to work and actually autoload. Any help is greatly appreciated.

Dmitry.

Parent Message unknown Re: Where to put my custom validators?

by Mike Willbanks-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

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

 

----- Original Message -----

From: dmitrybelyakov

Sent: 06/30/09 02:03 pm

To: fw-mvc@...

Subject: [fw-mvc] Where to put my custom validators?

 


Hello everybody,

I just wonder if there's a default or recommended location for custom
validator classes that go along with my module's forms. I am having trouble
getting it to work and actually autoload. Any help is greatly appreciated.

Dmitry.
--
View this message in context: http://www.nabble.com/Where-to-put-my-custom-validators--tp24277729p24277729.html
Sent from the Zend MVC mailing list archive at Nabble.com.

 



Re: Where to put my custom validators?

by dmitrybelyakov :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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.

Re: Where to put my custom validators?

by Nicolas GREVET :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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.
>
>