PHP code example of alpha-zeta / validation

1. Go to this page and download the library: Download alpha-zeta/validation library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

alpha-zeta / validation example snippets


use Az\Validation\Middleware\ValidationMiddleware;
use Auth\Model\ModelUser;
use Psr\Http\Message\ServerRequestInterface;

class DataValidation extends ValidationMiddleware
{
    public function __construct(private ModelUser $modelUser){}

    protected function setRules(ServerRequestInterface $request)
    {
        $this->validation->rule('username', '

use Az\Validation\Validation;
use Auth\Model\ModelUser;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Server\RequestHandlerInterface;

class DataValidation extends ValidationMiddleware
{
    public function __construct(
        private Validation $validation,
        private ModelUser $modelUser
    ){}

    public function process(
        ServerRequestInterface $request,
        RequestHandlerInterface $handler
    ): ResponseInterface
    {
        $this->validation->rule('username', 'quest->getServerParams()['HTTP_REFERER'], 302);
        }

        unset($data['confirm']);
        unset($data['agree']);

        return $handler->handle($request->withParsedBody($data));
    }
}