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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.