PHP code example of yljphp / validation

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

    

yljphp / validation example snippets



class RequestDemo implements RequestInterface
{
    public function rules()
    {
        return [
            'username' => 'quired'             => ':attribute 不能为空须。',
            'min'                  => ':attribute 至少为 :min 个字符。',//或直接直接写名字最少5个字符
        ];
    }

    public function getRequestData()
    {
        return [
            'username' => 'sssss'
        ];
        //通过其他方法获取要验证的参数数组
    }

    public function attributes()
    {
        return [
            'username' => '用户名',
            'password' => '密码',
        ];
    }

}




request_validate(new RequestDemo(),$errors)