PHP code example of team-moment / validator

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

    

team-moment / validator example snippets



use Moment\Validator\Validator;

// 增加规则扩展
Validator::addExtension(
    'channel',
    function ($field, $value, array $parameters = []) {
        return false !== array_search($value, ['google', 'bing']);
    },
    false
);

$data = [
    'blog' => 'https://github.com/RunnerLee',
];
$rule = [
    'blog' => '

$data = [
    'foo' => '',
];

$rules= [
    'foo' => 'string',
];