定制 digitalrevolution/symfony-validation-shorthand 二次开发

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

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

digitalrevolution/symfony-validation-shorthand

最新稳定版本:v2.0.1

Composer 安装命令:

composer require digitalrevolution/symfony-validation-shorthand

包简介

Validation shorthand for symfony

README 文档

README

Minimum PHP Version Minimum Symfony Version Run tests

Symfony Validation Shorthand

A validation shorthand component for Symfony, similar to the syntax in the "illuminate/validator" package for Laravel.

Installation

Include the library as dependency in your own project via:

composer require "digitalrevolution/symfony-validation-shorthand"

Usage

Example

$rules = [
    'name.first_name' => 'required|string|min:5',
    'name.last_name'  => 'string|min:6',                     // last name is optional
    'email'           => 'required|email',
    'password'        => 'required|string|between:7,40',
    'phone_number'    => 'required|regex:/^020\d+$/',
    'news_letter'     => 'required|bool',
    'tags?.*'         => 'required|string'                   // if tags is set, must be array of all strings with count > 0 
];        

// transform the rules into a Symfony Constraint tree
$constraint = (new ConstraintFactory)->fromRuleDefinitions($rules);

// validate the data
$violations = \Symfony\Component\Validator\Validation::createValidator()->validate($data, $constraint);

Validates:

[
    'name'         => [
        'first_name' => 'Peter',
        'last_name'  => 'Parker'
    ],
    'email'        => 'example@example.com',
    'password'     => 'hunter8',
    'phone_number' => '0201234678',
    'news_letter'  => 'on',
    'tags'         => ['sports', 'movies', 'music']           
]

Documentation

Full syntax and examples:

About us

At 123inkt (Part of Digital Revolution B.V.), every day more than 50 development professionals are working on improving our internal ERP and our several shops. Do you want to join us? We are looking for developers.

统计信息

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

GitHub 信息

  • Stars: 12
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固