switon/validation 问题修复 & 功能扩展

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

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

switon/validation

Composer 安装命令:

composer require switon/validation

包简介

Attribute-driven validation with normalization and locale-aware error messages for Switon Framework

README 文档

README

CI PHP 8.3+

Switon's validation layer for constraint attributes, typed input conversion, and localized error messages.

Highlights

  • Constraint attributes: Required, Length, Email, and related attributes validate fields directly.
  • Typed values: Type and Defaults can fill and cast values during validation.
  • Validation flow: one-shot and manual validation are both supported.
  • Localized messages: template files provide per-locale fallback messages and labels.

Installation

composer require switon/validation

Quick Start

use Switon\Validating\Attribute\Defaults;
use Switon\Validating\Attribute\Email;
use Switon\Validating\Attribute\Length;
use Switon\Validating\Attribute\Required;
use Switon\Validating\Attribute\Type;
use Switon\Core\Attribute\Autowired;
use Switon\Validating\ValidatorInterface;

final class UserService
{
    #[Autowired] protected ValidatorInterface $validator;

    public function register(array $input): array
    {
        return $this->validator->validateValues($input, [
            'email' => [new Required(), new Email()],
            'name' => [new Required(), new Length(2, 32)],
            'age' => [new Defaults(18), new Type('int')],
        ]);
    }
}

Docs: https://docs.switon.dev/latest/validation

License

MIT.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固