Laravel中validation验证 返回中文提示 全局设置的方法


Posted in PHP onSeptember 29, 2019

更改 resources\lang 目录下边的 validation.php

<?php

return [

/*
|--------------------------------------------------------------------------
| Validation Language Lines
|--------------------------------------------------------------------------
|
| The following language lines contain the default error messages used by
| the validator class. Some of these rules have multiple versions such
| as the size rules. Feel free to tweak each of these messages here.
|
*/

'accepted'       => ':attribute必须接受',
'active_url'      => ':attribute必须是一个合法的 URL',
'after'        => ':attribute 必须是 :date 之后的一个日期',
'after_or_equal'    => ':attribute 必须是 :date 之后或相同的一个日期',
'alpha'        => ':attribute只能包含字母',
'alpha_dash'      => ':attribute只能包含字母、数字、中划线或下划线',
'alpha_num'      => ':attribute只能包含字母和数字',
'array'        => ':attribute必须是一个数组',
'before'        => ':attribute 必须是 :date 之前的一个日期',
'before_or_equal'   => ':attribute 必须是 :date 之前或相同的一个日期',
'between'       => [
  'numeric' => ':attribute 必须在 :min 到 :max 之间',
  'file'  => ':attribute 必须在 :min 到 :max KB 之间',
  'string' => ':attribute 必须在 :min 到 :max 个字符之间',
  'array'  => ':attribute 必须在 :min 到 :max 项之间',
],
'boolean'       =>':attribute字符必须是 true 或false, 1 或 0 ',
'confirmed'      => ':attribute 二次确认不匹配',
'date'         => ':attribute 必须是一个合法的日期',
'date_format'     => ':attribute 与给定的格式 :format 不符合',
'different'      => ':attribute 必须不同于 :other',
'digits'        => ':attribute必须是 :digits 位.',
'digits_between'    => ':attribute 必须在 :min 和 :max 位之间',
'dimensions'      => ':attribute具有无效的图片尺寸',
'distinct'       => ':attribute字段具有重复值',
'email'        => ':attribute必须是一个合法的电子邮件地址',
'exists'        => '选定的 :attribute 是无效的.',
'file'         => ':attribute必须是一个文件',
'filled'        => ':attribute的字段是必填的',
'image'        => ':attribute必须是 jpeg, png, bmp 或者 gif 格式的图片',
'in'          => '选定的 :attribute 是无效的',
'in_array'       => ':attribute 字段不存在于 :other',
'integer'       => ':attribute 必须是个整数',
'ip'          => ':attribute必须是一个合法的 IP 地址。',
'json'         => ':attribute必须是一个合法的 JSON 字符串',
'max'         => [
  'numeric' => ':attribute 的最大长度为 :max 位',
  'file'  => ':attribute 的最大为 :max',
  'string' => ':attribute 的最大长度为 :max 字符',
  'array'  => ':attribute 的最大个数为 :max 个.',
],
'mimes'        => ':attribute 的文件类型必须是 :values',
'min'         => [
  'numeric' => ':attribute 的最小长度为 :min 位',
  'file'  => ':attribute 大小至少为 :min KB',
  'string' => ':attribute 的最小长度为 :min 字符',
  'array'  => ':attribute 至少有 :min 项',
],
'not_in'        => '选定的 :attribute 是无效的',
'numeric'       => ':attribute 必须是数字',
'present'       => ':attribute 字段必须存在',
'regex'        => ':attribute 格式是无效的',
'required'       => ':attribute 字段是必须的',
'required_if'     => ':attribute 字段是必须的当 :other 是 :value',
'required_unless'   => ':attribute 字段是必须的,除非 :other 是在 :values 中',
'required_with'    => ':attribute 字段是必须的当 :values 是存在的',
'required_with_all'  => ':attribute 字段是必须的当 :values 是存在的',
'required_without'   => ':attribute 字段是必须的当 :values 是不存在的',
'required_without_all' => ':attribute 字段是必须的当 没有一个 :values 是存在的',
'same'         => ':attribute和:other必须匹配',
'size'         => [
  'numeric' => ':attribute 必须是 :size 位',
  'file'  => ':attribute 必须是 :size KB',
  'string' => ':attribute 必须是 :size 个字符',
  'array'  => ':attribute 必须包括 :size 项',
],
'string'        => ':attribute 必须是一个字符串',
'timezone'       => ':attribute 必须是个有效的时区.',
'unique'        => ':attribute 已存在',
'url'         => ':attribute 无效的格式',

/*
|--------------------------------------------------------------------------
| Custom Validation Language Lines
|--------------------------------------------------------------------------
|
| Here you may specify custom validation messages for attributes using the
| convention "attribute.rule" to name the lines. This makes it quick to
| specify a specific custom language line for a given attribute rule.
|
*/

'custom' => [
  'attribute-name' => [
    'rule-name' => 'custom-message',
  ],
],

/*
|--------------------------------------------------------------------------
| Custom Validation Attributes
|--------------------------------------------------------------------------
|
| The following language lines are used to swap attribute place-holders
| with something more reader friendly such as E-Mail Address instead
| of "email". This simply helps us make messages a little cleaner.
|
*/

'attributes' => [
  // 'name'     => '名字',
  // 'age'     => '年龄',
],

];

以上这篇Laravel中validation验证 返回中文提示 全局设置的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持三水点靠木。

PHP 相关文章推荐
PHP array_flip() 删除重复数组元素专用函数
May 16 PHP
php中一个完整表单处理实现代码
Nov 10 PHP
linux下安装php的memcached客户端
Aug 03 PHP
thinkphp浏览历史功能实现方法
Oct 29 PHP
php中Ctype函数用法详解
Dec 09 PHP
php自动更新版权信息显示的方法
Jun 19 PHP
Yii使用技巧大汇总
Dec 29 PHP
分享PHP-pcntl 实现多进程代码
Sep 30 PHP
php封装的单文件(图片)上传类完整实例
Oct 18 PHP
Laravel框架搜索分页功能示例
Feb 01 PHP
PHP中引用类型和值类型功能与用法示例
Feb 26 PHP
ThinkPHP 5.1 跨域配置方法
Oct 11 PHP
Laravel自定义 封装便捷返回Json数据格式的引用方法
Sep 29 #PHP
laravel dingo API返回自定义错误信息的实例
Sep 29 #PHP
Laravel框架Auth用户认证操作实例分析
Sep 29 #PHP
laravel Validator ajax返回错误信息的方法
Sep 29 #PHP
Laravel框架实现文件上传的方法分析
Sep 29 #PHP
laravel http 自定义公共验证和响应的方法
Sep 29 #PHP
laravel5.2表单验证,并显示错误信息的实例
Sep 29 #PHP
You might like
PHP使用strtotime计算两个给定日期之间天数的方法
2015/03/18 PHP
javascript实现动态增加删除表格行(兼容IE/FF)
2007/04/02 Javascript
Javascript 键盘keyCode键码值表
2009/12/24 Javascript
用jquery生成二级菜单的实例代码
2013/06/24 Javascript
js判断上传文件的类型和大小示例代码
2013/10/18 Javascript
jquery实现个人中心导航菜单效果和美观都非常不错
2014/09/02 Javascript
用C/C++来实现 Node.js 的模块(一)
2014/09/24 Javascript
jQuery操作复选框(CheckBox)的取值赋值实现代码
2017/01/10 Javascript
利用ES6语法重构React组件详解
2017/03/02 Javascript
vue中的非父子间的通讯问题简单的实例代码
2017/07/19 Javascript
基于vue v-for 多层循环嵌套获取行数的方法
2018/09/26 Javascript
微信小程序websocket实现即时聊天功能
2019/05/21 Javascript
vue-列表下详情的展开与折叠案例
2020/07/28 Javascript
vue-quill-editor 自定义工具栏和自定义图片上传路径操作
2020/08/03 Javascript
Ant Design moment对象和字符串之间的相互转化教程
2020/10/27 Javascript
[04:27]DOTA2官方论坛水友赛集锦
2013/09/16 DOTA
Python类方法__init__和__del__构造、析构过程分析
2015/03/06 Python
Python判断列表是否已排序的各种方法及其性能分析
2016/06/20 Python
Python实现树的先序、中序、后序排序算法示例
2017/06/23 Python
hmac模块生成加入了密钥的消息摘要详解
2018/01/11 Python
浅谈python numpy中nonzero()的用法
2018/04/02 Python
Flask框架踩坑之ajax跨域请求实现
2019/02/22 Python
Python选择网卡发包及接收数据包
2019/04/04 Python
把vgg-face.mat权重迁移到pytorch模型示例
2019/12/27 Python
python opencv进行图像拼接
2020/03/27 Python
html5使用Canvas绘图的使用方法
2017/11/21 HTML / CSS
欧洲、亚洲、非洲和拉丁美洲的度假套餐:Great Value Vacations
2019/03/30 全球购物
面试求职的个人自我评价
2013/11/16 职场文书
大二学生职业生涯规划书
2014/02/05 职场文书
承诺书范文
2014/06/03 职场文书
应聘护士求职信
2014/07/21 职场文书
党员批评与自我批评
2014/10/15 职场文书
2015年八一建军节活动总结
2015/03/20 职场文书
2015年实习生工作总结报告
2015/04/28 职场文书
我在伊朗长大观后感
2015/06/16 职场文书
为自由献出你的心脏!「进击的巨人展 FINAL」2022年6月在台开展
2022/04/13 日漫