kshabazz/whip-lash 问题修复 & 功能扩展

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

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

kshabazz/whip-lash

Composer 安装命令:

composer require kshabazz/whip-lash

包简介

Whip web tools for validation.

README 文档

README

Perform assertions on some input via a fluid interface. Allows you to quickly get started with some out-of-the-box general validation. Its also extend-able so that you can customize when needed and encourages re-usability. The fluid interface can also help to reduce testing efforts.

Description

A validation library with a fluid interface. Some features to note are that:

  • You can quickly get started with out-of-the-box general validation.
  • It can be extended by following a few steps.
  • It encourage reuseability
  • It can help reduce testing efforts.

How to use Out-of-the-box Validation

$validation = (new Validation())
    ->withMessages([ // These keys DO NOT have to match input keys.
       'fname' => 'name must be between 1-26 chars.',
       'fname_re' => 'can only contain spaces & letters.'
   ])
    ->withInput[
       'fnname' => 'First',
   ]);

$validation->assert('first_name')
    ->length(1, 26, 'fname')
    ->regExp('/^[a-zA-Z]+$/', 'fname_re);

$errors = $validation->getErrors();

How to build your Own Validation

So you want to scale the validation down/up to suit your needs and customize it to your application. Then you will need to extend the abstract the \Whip\Lash\Validator class and use some traits. You can either use the \Whip\Lash\Validators supplied with Lash, or [build your own](#How to Build your Own Validator).

use \Whip\Lash\Validators\Strings;

class FormValidation extents Validator
{
    use Strings; 
}

How to Build your Own Validator

Validators are just traits with functions. It was decided to use traits over classes and interfaces because the play nice with auto-completion and produce less spaghetti code.



                                    

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-08-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固