sylae / validator
PHP 验证器,用于各种事物。
v0.3.0
2020-05-11 10:08 UTC
This package is auto-updated.
Last update: 2024-09-16 22:35:45 UTC
README
这是一个用于各种事物的 PHP 验证器。
用法
包含 composer 的自动加载并初始化一个实例。
<?php // include autoloader //This one will not fail $nofail = CharlotteDunois\Validation\Validator::make( array( 'username' => 'CharlotteDunois', 'email' => 'noreply@github.com' ), array( 'username' => 'string|required|min:5|max:75', 'email' => 'email' ) ); var_dump($nofail->passes()); //This one will fail due to invalid email $fail = CharlotteDunois\Validation\Validator::make( array( 'username' => 'CharlotteDuois', 'email' => 'noreply@githubcom' ), array( 'username' => 'string|required|min:5|max:75', 'email' => 'email' ) ); var_dump($fail->passes(), $fail->errors());