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 购物车的例子
May 04 PHP
PHP 危险函数全解析
Sep 09 PHP
一个PHP的远程图片抓取函数分享
Sep 25 PHP
php中通过curl检测页面是否被百度收录
Sep 27 PHP
php实现简单文件下载的方法
Jan 30 PHP
PHP用FTP类上传文件视频等的简单实现方法
Sep 23 PHP
php redis实现对200w用户的即时推送
Mar 04 PHP
PHP异步进程助手async-helper
Feb 05 PHP
Thinkphp5 自定义上传文件名的实现方法
Jul 23 PHP
laravel 实现向公共模板中传值 (view composer)
Oct 22 PHP
phpcmsv9.0任意文件上传漏洞解析
Oct 20 PHP
PHP7 其他修改
Mar 09 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 中执行系统外部命令
2006/10/09 PHP
解析php session_set_save_handler 函数的用法(mysql)
2013/06/29 PHP
php列出mysql表所有行和列的方法
2015/03/13 PHP
PHP正则判断一个变量是否为正整数的方法
2019/02/27 PHP
PHP常用的类封装小结【4个工具类】
2019/06/28 PHP
关于B/S判断浏览器断开的问题讨论
2008/10/29 Javascript
Ext grid 添加右击菜单
2009/11/26 Javascript
原生的html元素选择器类似jquery选择器
2014/10/15 Javascript
Angular用来控制元素的展示与否的原生指令介绍
2015/01/07 Javascript
详解JavaScript的Polymer框架中的通知交互
2015/07/29 Javascript
javascript实现对表格元素进行排序操作
2015/11/18 Javascript
跟我学习javascript的this关键字
2020/05/28 Javascript
jquery判断输入密码两次是否相等
2020/04/22 Javascript
JS实用的带停顿的逐行文本循环滚动效果实例
2016/11/23 Javascript
JS实现简单短信验证码界面
2017/08/07 Javascript
js实现简单选项卡功能
2020/03/23 Javascript
JS合并两个数组的3种方法详解
2019/10/24 Javascript
[02:07]DOTA2新英雄展现中国元素,完美“圣典”亮相央视
2016/12/19 DOTA
Python实现简单多线程任务队列
2016/02/27 Python
python 获取网页编码方式实现代码
2017/03/11 Python
Python简单读取json文件功能示例
2017/11/30 Python
python自动化测试之如何解析excel文件
2019/06/27 Python
细说NumPy数组的四种乘法的使用
2020/12/18 Python
详解使用scrapy进行模拟登陆三种方式
2021/02/21 Python
高级3D打印市场:Gambody
2019/12/26 全球购物
如何从一个文件档案的尾端新增记录
2016/12/02 面试题
个人自我鉴定
2013/11/07 职场文书
采购文员岗位职责
2013/11/20 职场文书
信访工作者先进事迹
2014/01/17 职场文书
办公室主任先进事迹
2014/01/18 职场文书
GMP办公室主任岗位职责
2014/03/14 职场文书
报告会主持词
2014/04/02 职场文书
供货协议书范本
2014/04/22 职场文书
群众路线剖析材料(四风问题)
2014/10/08 职场文书
2014党的群众路线教育实践活动总结报告
2014/10/31 职场文书
乡镇团代会开幕词
2016/03/04 职场文书