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 遍历XP文件夹下所有文件
Nov 27 PHP
php 文件上传类代码
Aug 06 PHP
php.ini-dist 和 php.ini-recommended 的区别介绍(方便开发与安全的朋友)
Jul 01 PHP
解析php中获取系统信息的方法
Jun 25 PHP
PHP实现简单搜歌的方法
Jul 28 PHP
使用xampp搭建运行php虚拟主机的详细步骤
Oct 21 PHP
非常经典的PHP文件上传类分享
May 15 PHP
PHP实现将MySQL重复ID二维数组重组为三维数组的方法
Aug 01 PHP
PHP面向对象程序设计之类与反射API详解
Dec 02 PHP
laravel项目利用twemproxy部署redis集群的完整步骤
May 11 PHP
php中的explode()函数实例介绍
Jan 18 PHP
Laravel框架Auth用户认证操作实例分析
Sep 29 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实现的支持imagemagick及gd库两种处理的缩略图生成类
2014/09/23 PHP
PHP getDocNamespaces()函数讲解
2019/02/03 PHP
javascript String 的扩展方法集合
2008/06/01 Javascript
ASP.NET jQuery 实例6 (实现CheckBoxList成员全选或全取消)
2012/01/13 Javascript
正则表达式中特殊符号及正则表达式的几种方法总结(replace,test,search)
2013/11/26 Javascript
javascript获取wx.config内部字段解决微信分享
2016/03/09 Javascript
通用无限极下拉菜单的实现代码
2016/05/31 Javascript
JavaScript函数节流概念与用法实例详解
2016/06/20 Javascript
Angularjs单选改为多选的开发过程及问题解析
2017/02/17 Javascript
微信小程序 template模板详解及实例
2017/02/21 Javascript
微信小程序 开发之全局配置
2017/05/05 Javascript
ionic3+Angular4实现接口请求及本地json文件读取示例
2017/10/11 Javascript
swiper移动端轮播插件(触碰图片之后停止轮播)
2017/12/28 Javascript
vue生命周期实例小结
2018/08/15 Javascript
小程序绑定用户方案优化小结
2019/05/15 Javascript
vue实现一个获取按键展示快捷键效果的Input组件
2021/01/13 Vue.js
python中urllib模块用法实例详解
2014/11/19 Python
python中文分词,使用结巴分词对python进行分词(实例讲解)
2017/11/14 Python
python 通过logging写入日志到文件和控制台的实例
2018/04/28 Python
对pandas将dataframe中某列按照条件赋值的实例讲解
2018/11/29 Python
从0开始的Python学习014面向对象编程(推荐)
2019/04/02 Python
Python数据类型之List列表实例详解
2019/05/08 Python
python 爬虫 实现增量去重和定时爬取实例
2020/02/28 Python
纯CSS实现聊天框小尖角、气泡效果
2014/04/04 HTML / CSS
CSS3提交意见输入框样式代码
2014/10/30 HTML / CSS
html5自定义video标签的海报与播放按钮功能
2019/12/04 HTML / CSS
土耳其玩具商店:Toyzz Shop
2019/08/02 全球购物
中专自我鉴定
2014/02/05 职场文书
成语的广告词
2014/03/19 职场文书
请假条怎么写
2014/04/10 职场文书
《望庐山瀑布》教学反思
2014/04/22 职场文书
政府班子四风问题整改措施
2014/10/04 职场文书
乡镇党的群众路线教育实践活动个人整改方案
2014/10/31 职场文书
通知函的格式
2015/04/27 职场文书
学校世界艾滋病日宣传活动总结
2015/05/05 职场文书
4种非常实用的python内置数据结构
2021/04/28 Python