承接 stantabcorp/validator 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

stantabcorp/validator

最新稳定版本:1.3.0

Composer 安装命令:

composer require stantabcorp/validator

包简介

A PHP Validation library

README 文档

README

A simple PHP validation library

PHP Composer

Installation

composer require stantabcorp/validator

Using the library

$validator = new \Stantabcorp\Validator\Validator(["array" => ["to" => "validate"]]); // Init the library providing an array to validate.
$validator->required("array.to"); // Test if the key `to` in the array `array` is present.
$validator->array("array"); // Test if the key `array` is an array.

$validator->isValid(); // Return a boolean is the array is valid or not.

$validator->getErrors(); // Return a list of string containing the error messages.

Custom validation

$validator->customValidation("array", function (\Stantabcorp\Validator\CustomValidator $customValidator) {
    $customValidator->getKey(); // The key (`array` in this case)
    $customValidator->getValue(); // The associated value
    
    // Mark the kay as invalid and add an error message.
    $customValidator->addError("This is an error message");
});

Testing

composer run-script test

统计信息

  • 总下载量: 1.53k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-03-21