O'Reilly logo

PHP 7 Programming Cookbook by Doug Bierer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chaining $_POST validators

The heavy lifting for this recipe has already been accomplished in the preceding recipe. Core functionality is defined by Application\Filter\AbstractFilter. The actual validation is performed by an array of validating callbacks.

How to do it...

  1. Look over the preceding recipe, Chaining $_POST filters. We will be using all of the classes and configuration files in this recipe, except where noted here.
  2. To begin, we define a configuration array of validation callbacks. As with the preceding recipe, each callback should implement Application\Filter\CallbackInterface, and should return an instance of Application\Filter\Result. Validators would take this generic form:
    use Application\Filter\ { Result, Messages, CallbackInterface ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required