A free and open-source book on Zend Framework for beginners


9. Checking Input Data with Validators

In this chapter, we will provide an overview of standard ZF validators that can be used with your forms, and will also show how to write a custom validator. A validator is a class designed to take some input data, check it for correctness, and return a boolean result telling whether the data is correct (and error messages if the data has some errors).

In general, you even can use validators outside forms to process an arbitrary data. For example, validators may be used in a controller action to ensure that data passed as GET and/or POST variables is secure and conform to certain format.

ZF3 components covered in this chapter:

Component Description
Zend\Validator Implements various validator classes.
Zend\InputFilter Implements a container for filters/validators.


Top