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 相关文章推荐
解决dede生成静态页和动态页转换的一些问题,及火车采集入库生成动态的办法
Mar 29 PHP
php 清除网页病毒的方法
Dec 05 PHP
php 删除一个数组中的某个值.兼容多维数组!
Feb 18 PHP
基于flush()不能按顺序输出时的解决办法
Jun 29 PHP
php获取中文拼音首字母类和函数分享
Apr 24 PHP
PHP程序员基本要求和必备技能
May 09 PHP
PHP PDO fetch 模式各种参数的输出结果一览
Jan 07 PHP
浅谈json_encode用法
Mar 05 PHP
将PHP的session数据存储到数据库中的代码实例
Jun 24 PHP
PHP使用Redis替代文件存储Session的方法
Feb 15 PHP
Yii2框架中一些折磨人的坑
Dec 15 PHP
php使用redis的几种常见操作方式和用法示例
Feb 20 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/12/06 PHP
CakePHP去除默认显示的标题及图标的方法
2008/10/22 PHP
PHP投票系统防刷票判断流程分析
2012/02/04 PHP
php获取网站百度快照日期的方法
2015/07/29 PHP
PHP比较运算符的详细介绍
2015/09/29 PHP
PHP使用redis实现统计缓存mysql压力的方法
2015/11/14 PHP
PHP如何获取当前主机、域名、网址、路径、端口等参数
2017/06/09 PHP
PHP如何通过表单直接提交大文件详解
2019/01/08 PHP
JavaScript 异步调用框架 (Part 3 - 代码实现)
2009/08/04 Javascript
jQuery Flash/MP3/Video多媒体插件
2010/01/18 Javascript
jquery 图片 上一张 下一张 链接效果(续篇)
2010/04/20 Javascript
File, FileReader 和 Ajax 文件上传实例分析(php)
2011/04/27 Javascript
将nodejs打包工具整合到鼠标右键的方法
2013/05/11 NodeJs
jquery中交替点击事件toggle方法的使用示例
2013/12/08 Javascript
js实现对table动态添加、删除和更新的方法
2015/02/10 Javascript
解决vue2中使用axios http请求出现的问题
2018/03/05 Javascript
JQuery中DOM节点的操作与访问方法实例分析
2019/12/23 jQuery
Python Requests 基础入门
2016/04/07 Python
python DataFrame 修改列的顺序实例
2018/04/10 Python
详解Python 装饰器执行顺序迷思
2018/08/08 Python
Scrapy框架爬取Boss直聘网Python职位信息的源码
2019/02/22 Python
基于多进程中APScheduler重复运行的解决方法
2019/07/22 Python
安装Pycharm2019以及配置anconda教程的方法步骤
2019/11/11 Python
python socket 聊天室实例代码详解
2019/11/14 Python
解决python彩色螺旋线绘制引发的问题
2019/11/23 Python
使用tensorflow实现矩阵分解方式
2020/02/07 Python
pytorch实现Tensor变量之间的转换
2020/02/17 Python
Python操作Excel把数据分给sheet
2020/05/20 Python
摩顿布朗英国官方网上商店:奢华沐浴、身体和头发护理
2016/10/29 全球购物
酒店员工职业生涯规划
2014/02/25 职场文书
2014副局长群众路线对照检查材料思想汇报
2014/09/22 职场文书
机关作风建设工作总结
2014/10/23 职场文书
离婚起诉书范本
2015/05/18 职场文书
小学生节约用水倡议书
2019/08/12 职场文书
python读取pdf格式文档的实现代码
2021/04/01 Python
Python中常见的导入方式总结
2021/05/06 Python