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 相关文章推荐
UCenter中的一个可逆加密函数authcode函数代码
Jul 20 PHP
查找mysql字段中固定字符串并替换的几个方法
Sep 23 PHP
PHP中的函数-- foreach()的用法详解
Jun 24 PHP
解析web文件操作常见安全漏洞(目录、文件名检测漏洞)
Jun 29 PHP
用Zend Studio+PHPnow+Zend Debugger搭建PHP服务器调试环境步骤
Jan 19 PHP
php获得用户ip地址的比较不错的方法
Feb 08 PHP
php中socket的用法详解
Oct 24 PHP
php中fsockopen用法实例
Jan 05 PHP
thinkPHP数据库增删改查操作方法实例详解
Dec 06 PHP
php 浮点数比较方法详解
May 05 PHP
PHP 访问数据库配置通用方法(json)
May 20 PHP
对php 判断http还是https,以及获得当前url的方法详解
Jan 15 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
与空气斗智斗勇的经典《Overlord》,传说中的“无稽之谈”
2020/04/09 日漫
咖啡常见的种类
2021/03/03 新手入门
php设计模式之简单工厂模式详解
2014/09/04 PHP
微信支付PHP SDK之微信公众号支付代码详解
2015/12/09 PHP
php上传图片并压缩的实现方法
2015/12/22 PHP
Laravel实现批量更新多条数据
2020/04/06 PHP
Z-Blog中用到的js代码
2007/03/15 Javascript
浅谈JavaScript之事件绑定
2013/07/08 Javascript
用js格式化金额可设置保留的小数位数
2014/05/09 Javascript
jQuery实现的多级下拉菜单效果代码
2015/08/24 Javascript
jQuery如何封装输入框插件
2016/08/19 Javascript
详解JavaScript的内置对象
2016/12/07 Javascript
浅谈js script标签中的预解析
2016/12/30 Javascript
jQuery时间验证和转换为标准格式的时间格式
2017/03/06 Javascript
本地搭建微信小程序服务器的实现方法
2017/10/27 Javascript
IE8中jQuery.load()加载页面不显示的原因
2018/11/15 jQuery
vue实现简单的登录弹出框
2020/10/26 Javascript
Python语言描述机器学习之Logistic回归算法
2017/12/21 Python
Python切片索引用法示例
2018/05/15 Python
Django ManyToManyField 跨越中间表查询的方法
2018/12/18 Python
Python使用pyshp库读取shapefile信息的方法
2018/12/29 Python
详解python和matlab的优势与区别
2019/06/28 Python
更新pip3与pyttsx3文字语音转换的实现方法
2019/08/08 Python
解决Python列表字符不区分大小写的问题
2019/12/19 Python
tensorflow中tf.reduce_mean函数的使用
2020/04/19 Python
利用python下载scihub成文献为PDF操作
2020/07/09 Python
pycharm 代码自动补全的实现方法(图文)
2020/09/18 Python
基于Html5 canvas实现裁剪图片和马赛克功能及又拍云上传图片 功能
2019/07/09 HTML / CSS
美体小铺加拿大官方网站:The Body Shop加拿大
2016/10/30 全球购物
银行领导证婚词
2014/01/11 职场文书
党员干部承诺书
2014/03/25 职场文书
毕业生见习报告总结
2014/11/08 职场文书
幼儿教师2014年度工作总结
2014/12/16 职场文书
单位租车协议书
2015/01/29 职场文书
应届毕业生自荐信
2015/03/04 职场文书
幼儿园推普周活动总结
2015/05/07 职场文书