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 危险函数解释 分析
Apr 22 PHP
PHP array_multisort()函数的使用札记
Jul 03 PHP
基于PHP一些十分严重的缺陷详解
Jun 03 PHP
php替换字符串中间字符为省略号的方法
May 04 PHP
php获取指定范围内最接近数的方法
Jun 02 PHP
PHP将二维数组某一个字段相同的数组合并起来的方法
Feb 26 PHP
PHP针对伪静态的注入总结【附asp与Python相关代码】
Aug 01 PHP
PHP实现自动发送邮件功能代码(qq 邮箱)
Aug 18 PHP
PHP中创建和编辑Excel表格的方法
Sep 13 PHP
laravel自定义分页的实现案例offset()和limit()
Oct 15 PHP
php的无刷新操作实现方法分析
Feb 28 PHP
thinkphp 获取控制器及控制器方法
Apr 16 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小教程之实现链表
2014/06/09 PHP
PHP实现Javascript中的escape及unescape函数代码分享
2015/02/10 PHP
ExtJS扩展 垂直tabLayout实现代码
2009/06/21 Javascript
jQuery中的.bind()、.live()和.delegate()之间区别分析
2011/06/08 Javascript
ASP.NET jQuery 实例13 原创jQuery文本框字符限制插件-TextArea Counter
2012/02/03 Javascript
js如何获取file控件的完整路径具体实现代码
2013/05/15 Javascript
js之ActiveX控件使用说明 new ActiveXObject()
2014/03/03 Javascript
纯js实现瀑布流布局及ajax动态新增数据
2016/04/07 Javascript
jQuery实现订单提交页发送短信功能前端处理方法
2016/07/04 Javascript
jQuery实现百度登录框的动态切换效果
2017/04/21 jQuery
angularJs中datatable实现代码
2017/06/03 Javascript
浅谈在Vue-cli里基于axios封装复用请求
2017/11/06 Javascript
Vue中使用webpack别名的方法实例详解
2018/06/19 Javascript
vue基础之data存储数据及v-for循环用法示例
2019/03/08 Javascript
JavaScript解析JSON数据示例
2019/07/16 Javascript
浅谈layui 绑定form submit提交表单的注意事项
2019/10/25 Javascript
vue2路由基本用法实例分析
2020/03/06 Javascript
[57:31]DOTA2-DPC中国联赛 正赛 SAG vs CDEC BO3 第一场 2月1日
2021/03/11 DOTA
python实现html转ubb代码(html2ubb)
2014/07/03 Python
基于python 爬虫爬到含空格的url的处理方法
2018/05/11 Python
用python简单实现mysql数据同步到ElasticSearch的教程
2018/05/30 Python
Python实现KNN(K-近邻)算法的示例代码
2019/03/05 Python
对Django中内置的User模型实例详解
2019/08/16 Python
pycharm 关掉syntax检查操作
2020/06/09 Python
如何在python中判断变量的类型
2020/07/29 Python
联想美国官方商城:Lenovo美国
2017/06/19 全球购物
澳大利亚旅游网站:Lastminute
2017/08/07 全球购物
真正的英国宝藏:Mappin & Webb
2019/05/05 全球购物
什么是数据抽象
2016/11/26 面试题
会计电算一体化个人简历的自我评价
2013/10/15 职场文书
应届毕业生个人自荐信范文
2013/11/30 职场文书
考试作弊检讨书1000字(5篇)
2014/10/19 职场文书
2014年服务员工作总结
2014/11/18 职场文书
党性修养心得体会2016
2016/01/21 职场文书
自从在 IDEA 中用了热部署神器 JRebel 之后,开发效率提升了 10(真棒)
2021/06/26 Java/Android
海康机器人重磅发布全新算法开发平台VM4.2
2022/04/21 数码科技