PHP code example of uniondrug / validation

1. Go to this page and download the library: Download uniondrug/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/ */

    

uniondrug / validation example snippets


return [
    'default' => [
        ......
        'providers'           => [
            ......
            \Uniondrug\Validation\ValidationServiceProvider::class,
        ],
    ],
];


$rules = [
            'id' => [
                'type' => 'int',
                '     '


class ApiRequestStruct extends Struct
{
    /**
     * @var int
     *
     * @Validator(type={int,"\App\Validators\MyValidator"})
     */
    public $id;

    /**
     * @var string
     */
    public $name;
}

class IndexController extents Controller
{
    public function indexAction()
    {
        $input = $this->request->getJsonRawBody();
        $rules = [
            'id' => [
                'type' => 'int',
                '

class IndexController extents Controller
{
    public function indexAction()
    {
        try {
            $apiStruct = ApiRequestStruct::factory($this->request->get());
            return $this->serviceServer->withObject($data->toArray())->response();
        } catch (\Exception $e) {
            return $this->serviceServer->withError($e->getMessage(), $e->getCode())->response();
        }

        ....
    }
}