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

Get PHP 7 Programming Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.