carlosv2/can 问题修复 & 功能扩展

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

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

carlosv2/can

Composer 安装命令:

composer require carlosv2/can

包简介

Tool for easy and powerful data validations

README 文档

README

Tool for easy and powerful data validations.

License Build Status SensioLabsInsight

Why

Imagine I give you this data:

$data = [
	'key1' => 123,
	'key2' => 'abc',
	'key3' => true
];

And then I ask you to validate it according to the following constraints:

  • It must be an array.
  • key1 must contain an integer between 100 and 200.
  • key2 must contain a non-empty string.
  • key3 must contain either a boolean or a callable.
  • If key4 is set, it must be an array with a maximum of 3 items.
  • It cannot have any other key.

How long would your code to validate $data be?

Using this project, it can be validated with this code:

can($data)->claim(To::beArray()
    ->withKey('key1')->expected(To::beInteger()->withMin(100)->withMax(200))
    ->withKey('key2')->expected(To::beString()->withMinLength(1))
    ->withKey('key3')->expected(To::beOneOf(To::beBoolean(), To::beCallable()))
    ->withKey('key4')->expected(To::beOptionalAnd(To::beArray()->withMaxCount(3)))
    ->withNoOtherKeys()
);

Install

Open a command console, enter your project directory and execute the following command to download the latest stable version of this project:

$ composer require carlosv2/can

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.

Documentation

Available documentation:

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-05-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固