narokishi/object-validator

用于验证对象的 PHP 包

dev-master 2018-09-01 15:42 UTC

This package is not auto-updated.

Last update: 2024-09-23 18:33:01 UTC


README

描述

"ObjectValidator" 是一个 PHP 包,它允许使用自定义规则验证给定的类(例如,从请求中接收的 stdClass)。强烈推荐用于通用视图。

安装

Composer

通过 Composer 安装将为您保持此包的最新状态。

composer require narokishi/object-validator

使用

use Narokishi\ObjectValidator\Validators\CompensationValidator;
use Narokishi\ObjectValidator\ValidationException;

...

try {
    (new CompensationValidator($class))
        ->applyPrefix('compensation')
        ->withThrow();
} catch (ValidationException $e) {
    // Apply errors to view or whatever
}

贡献

感谢您考虑为该包做出贡献。

运行测试

composer tests
composer tests-windows

提交补丁

  • 仓库分支
  • 操作完成后,在本地克隆您的分支
git clone git@github.com:{username}/object-validator.git
cd number-to-words
git remote add upstream git://github.com/narokishi/object-validator.git
  • 确保测试通过
  • 创建并工作在您自己的主题分支上
git checkout -b {branch} master
  • 准备您的补丁(在变基的过程中,您可能需要解决冲突)
git checkout master
git fetch upstream
git merge upstream/master
git checkout BRANCH_NAME
git rebase master
  • 如果发生冲突
 git add {files}
 git rebase --continue
  • 确保所有测试都通过并推送您的分支
 git push origin {branch} --force
  • 在 narokishi/object-validator 仓库上提交 Pull Request