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.
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.
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 ofApplication\Filter\Result
. Validators would take this generic form:use Application\Filter\ { Result, Messages, CallbackInterface }; $config = [ // validator callbacks 'validators' => [ 'key' => new class () implements CallbackInterface { public function __invoke($item, $params) : Result { // validation logic goes here return new...