laravel-discord/validator

此包已被放弃,不再维护。未建议替代包。

用于各种事物的PHP验证器。

v0.4.1 2020-10-20 07:47 UTC

This package is auto-updated.

Last update: 2022-12-06 04:49:26 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());

文档

https://charlottedunois.github.io/Validator/