定制 morfu/validator 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

morfu/validator

最新稳定版本:0.1.0

Composer 安装命令:

composer require morfu/validator

包简介

Composable pipeline of validators.

README 文档

README

Latest Version on Packagist Software License

NOT for production. API is NOT stable.

Example

use Morfu\Validator\ValidatorPipeline;

$badFormData = [
    'username' => 'Ali_Baba',
    'password' => 'ope sesme',
    'confirmPassword' => 'open sesame',
];

$passValidator = (new ValidatorPipeline())
    ->check(function ($length, $min) {
        return $length >= $min;
    })->message('Password length should be at least %min%.')
    ->param('min', 10)
    ->param('length', 'strlen')
    ->check(function ($input) {
        return (bool) preg_match('/\d+/', $input);
    })->message('Password should contain digits.')
    ->check(function ($input) {
        return (bool) preg_match('/[[:punct:]]+/', $input);
    })->message('Password should contain punctuation marks.');

$formValidator = (new ValidatorPipeline())
    ->checkField('password', $passValidator)
    ->check(function ($password, $confirmPassword) {
        return $password === $confirmPassword;
    })->message('Password and confirm password does not match.');

array_column($formValidator->getErrors($badFormData), 'message');
// => [
//    'Password length should be at least 10.',
//    'Password should contain digits.',
//    'Password should contain punctuation marks.',
//    'Password and confirm password does not match.',
//];

$formData = array_merge($badFormData, [
    'password' => 'open_sesame11',
    'confirmPassword' => 'open_sesame11',
]);

$formValidator->isValid($formData);
// => true

For further examples see tests/.

What is Morfu

Morfu (from Ancient Greek: μετᾰμορφόω, metamorphóō, "transform") is a set of pipeline-oriented PHP libraries.

What is Validator

Validator is a library of Morfu that provides composable pipeline of validators.

Install

Via Composer

$ composer require morfu/validator

Testing

$ make test

Security

If you discover any security related issues, please email kilych@zoho.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-11-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固