uuki/schemable-validator 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

uuki/schemable-validator

Composer 安装命令:

composer require uuki/schemable-validator

包简介

Schema based validation plugin.

README 文档

README

The Schemable Validator was developed to streamline the validation processing involved in form submissions.

✨ Features

  • 🍨 Vanilla PHP Based: Designed to be independent of specific systems such as CMS platforms.
  • Validation: Built on flexible and powerful validation processing using Respect/Validation, with sanitization features.
  • 📂 Data Store: Equipped with a controller that allows for easy storage of validated data for reuse across different pages and processes.
  • ⚙️ Customizability: Supports replaceable reply templates through aliases.

📦 Install

composer require uuki/schemable-validator:0.x@dev

🐣 Usage

Step 1.

Include plugin.

require_once __DIR__ . '/path/to/vendor/uuki/schemable-validator/src/index.php';

Step 2.

Create schema.

use Respect\Validation\Validator as v;

$schema = [
  'type' => v::notEmpty()
              ->setTemplate('Please select an item')
              ->in(['option1', 'option2', 'option3']),
  'name' => v::stringType()->length(1, 50),
  'email' => v::email(),
  'phone' => v::phone()->length(10, 15),
  'url' => v::url(),
  'address' => v::stringType()->length(1, 255),
  'body' => v::stringType()->length(1, 1000),
  'usage' => v::notEmpty()->in(['for_business', 'for_personal']),
  'docs' => v::key('error', v::equals(UPLOAD_ERR_OK))
    ->key('name', v::oneOf(
      v::extension('jpg'),
      v::extension('png'),
    )),
  'agreement' => v::trueVal()
];

Step 3.

Create validator instance.

use SchemableValidator\Validator;

$validator = new Validator($schema);

Step 4.

Validation at any time.

$result = $validator->validate($_POST);

More documentations

docs

Require

name versions
PHP ^7.4 || ^8.0 || ^8.1 || ^8.2

Dependencies

https://packagist.org/packages/respect/validation#2.2.4

Futures

  • Some options
    • reCAPTCHA
    • i18n

⛏️Plugin Development

Require

Setup

pnpm install
pnpm dev # start wp-content mode

Docs

https://github.com/WordPress/playground-tools/tree/trunk/packages/wp-now#automatic-modes

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-10-19