public static function validation(Service $api)
    {
        $validator = new Validator();
        return function (callable $handler) use ($api, $validator) {
            return function (
                CommandInterface $command,
                RequestInterface $request = null
            ) use ($api, $validator, $handler) {
                $operation = $api->getOperation($command->getName());
                $validator->validate(
                    $command->getName(),
                    $operation->getInput(),
                    $command->toArray()
                );
                return $handler($command, $request);
            };
        };
    }
public static function validation(Service $api)
    {
        $validator = new Validator();
        return function (callable $handler) use ($api, $validator) {
            return function (
                CommandInterface $command,
                RequestInterface $request = null
            ) use ($api, $validator, $handler) {
                $operation = $api->getOperation($command->getName());
                $validator->validate(
                    $command->getName(),
                    $operation->getInput(),
                    $command->toArray()
                );
                return $handler($command, $request);
            };
        };
    }
public static function validation ( Service $ api ) { $ validator = new Validator ( ) ; return function ( callable $ handler ) use ( $ api , $ validator ) { return function ( CommandInterface $ command , RequestInterface $ request = null ) use ( $ api , $ validator , $ handler ) { $ operation = $ api -> getOperation ( $ command -> getName ( ) ) ; $ validator -> validate ( $ command -> getName ( ) , $ operation -> getInput ( ) , $ command -> toArray ( ) ) ; return $ handler ( $ command , $ request ) ; } ; } ; }
Adds a middleware that uses client-side validation.

@param Service $api API being accessed.

@return callable
Adds a middleware that uses client - side validation .