定制 yuliusardian/validation 二次开发

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

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

yuliusardian/validation

Composer 安装命令:

composer require yuliusardian/validation

包简介

Use Laravel Validation outside of Laravel, This can be useful and helpful for validate any data for our projects.

README 文档

README

This validation package is based on Laravel Validation illuminate/validation, so we can use the Laravel Validation outside of Laravel and using it in our project with freedom.

Getting started

Requirements

  • PHP >= 5.6.4

Installation

$ composer -v require yuliusardian/validation

Or edit your composer.json and install it.

  "require": {
    "yuliusardian/validation": "1.0"
  }
$ composer -v install

Basic usage

<?php
/**
 * since we installed it via composer,  we've to call autoload, this is optional 
 */
 require_once 'path/to/composer-vendor/autoload.php';
 
 use YuliusArdian\Validation\Factory;

 $validator = new Factory;
 $data  = ['name' => 'Hasna Putri Rahmatunissa', 'email' => 'hsnaputri'];
 $rules = ['name' => 'required|max:10', 'email' => 'required|email'];
 
 $validator = $validator->make($data, $rules);
 $errors    = $validator->errors()->all();
 var_dump($errors); 

From the code above, it will return error :

string(47) "The name may not be greater than 10 characters."
string(40) "The email must be a valid email address."

Custom Language

By now, there is only two languages available for this package take a look the src/lang you will see en and id folder. the default language is en. Feel free if you want to contribute. Here's some example of using custom language :

<?php
$validator = new Factory('id');

More detail

For more detail about validation like custom message, available method, hooks, etc. Please visit the Laravel Validation Document

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固