Home » Php » php – where can I find a list of all the validators and filters of a Zend_Form?

php – where can I find a list of all the validators and filters of a Zend_Form?

Posted by: admin July 12, 2020 Leave a comment

Questions:

I’m learning Zend Framework using their manual at framework.zend.com.

where can I find the full list of all the validators and filters
that can be used in a Zend_Form ?

Using Zend Framework 1.11.6.

example:

filters: 'StringTrim' 

validators: 'EmailAddress'

thank you!

How to&Answers:

Check the following paths of your Zend Framework installation folder:

/Zend/Validate/*
/Zend/Filter/*

Or check the corresponding manual pages:

http://framework.zend.com/manual/en/zend.filter.html

http://framework.zend.com/manual/en/zend.validate.html

Answer:

You can use all the shipped filters & validators with zend-form aswell as custom ones.

Answer:

The usage, for anyone that got a little confused as I did, is to take the last part of any Zend_Validate_XYZ and use the XYZ as the string in any addValidator chain like so: ->addValidator(‘XYZ’) so for example, to validate an email address use the Zend_Validate_EmailAddress class or ->addValidator(‘EmailAddress’) on the elements variable

Don’t forget that the second parameter is whether a failure should break the chain. True breaks the chain, False does not. So, if we wanted to validate an Alpha only field and then an AlphaNumeric field but NOT break if the Alpha field !isValid() then:
->addValidator(‘Alpha’, FALSE)->addValidator(‘AlNum’, TRUE)