微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

laravel 表单请求验证中文提示文本msg

1、在 config/app.PHP 文件修改key为 ‘locale‘=>‘zh-CN‘;

2、在laravel框架根目录下的resources/lang目录创建 zh-CN/validation.PHP文件,在该文件添加一下验证提示文本:

  1     ‘accepted‘             => ‘参数 :attribute 验证的字段必须为 yes、 on、 1、或 true.‘,  2     ‘active_url‘           => ‘参数 :attribute 必须是一个合法的 URL.‘,  3     ‘after‘                => ‘参数 :attribute 必须是给定日期:date之后的值 .‘,  4     ‘after_or_equal‘       => ‘参数 :attribute 必须等于给定日期:date或:date之后的值 .‘,  5     ‘alpha‘                => ‘参数 :attribute 必须完全是中文或字母的字符.‘,  6     ‘alpha_dash‘           => ‘参数 :attribute 可能具有字母、数字、破折号( - )以及下划线( _ ).‘,  7     ‘alpha_num‘            => ‘参数 :attribute 必须完全是字母、数字.‘,  8     ‘array‘                => ‘参数 :attribute 必须是一个 PHP 数组.‘,  9     ‘before‘               => ‘参数 :attribute 必须是给定日期:date之前的值.‘, 10     ‘before_or_equal‘      => ‘参数 :attribute 必须等于给定日期:date或:date之后的值.‘, 11     ‘between‘              => [
 12         ‘numeric‘ => ‘:attribute 必须在 :min 到 :max 之间‘, 13         ‘file‘    => ‘:attribute 必须在 :min 到 :max KB之间‘, 14         ‘string‘  => ‘:attribute 必须在 :min 到 :max 个字符之间‘, 15         ‘array‘   => ‘:attribute 必须在 :min 到 :max 项之间‘, 16     ], 17     ‘boolean‘              => ‘参数 :attribute 必须能够被转换为布尔值(true 或者 false).‘, 18     ‘confirmed‘            => ‘参数 :attribute  二次确认不匹配.‘, 19     ‘date‘                 => ‘参数 :attribute 必须是通过 PHP 函数 strtotime 校验的有效日期,格式为:xxxx-xx-xx aa:bb:cc.‘, 20     ‘date_format‘          => ‘参数 :attribute 与给定的格式 :format不匹配.‘, 21     ‘different‘            => ‘参数 :attribute 必须不同于:other.‘, 22     ‘digits‘               => ‘参数 :attribute 必须是数字 :digits.‘, 23     ‘digits_between‘       => ‘参数 :attribute 数字长度必须在 :min 和 :max 之间.‘, 24     ‘dimensions‘           => ‘参数 :attribute必须是图片并且图片比例必须符合规则.‘, 25distinct‘             => ‘参数 :attribute 指定的字段不能有任何重复值.‘, 26     ‘email‘                => ‘参数 :attribute 必须符合 e-mail 地址格式.‘, 27     ‘exists‘               => ‘选定的 :attribute 是无效的.‘, 28     ‘file‘                 => ‘参数 :attribute 必须是成功上传文件.‘, 29     ‘filled‘               => ‘参数 :attribute 在存在时不能为空.‘, 30     ‘gt‘                   => [
 31         ‘numeric‘ => ‘The :attribute 必须大于 :value.‘, 32         ‘file‘    => ‘The :attribute 必须大于 :value KB.‘, 33         ‘string‘  => ‘The :attribute 必须大于 :value 个字符.‘, 34         ‘array‘   => ‘The :attribute 必须大于 :value 项.‘, 35     ], 36     ‘gte‘                  => [
 37         ‘numeric‘ => ‘参数 :attribute 必须大于或等于 :value.‘, 38         ‘file‘    => ‘参数 :attribute 必须大于或等于 :value KB.‘, 39         ‘string‘  => ‘参数 :attribute 必须大于或等于 :value 个字符.‘, 40         ‘array‘   => ‘参数 :attribute 必须大于或等于 :value 项.‘, 41     ], 42     ‘image‘                => ‘参数 :attribute 必须是一个图像( jpeg、png、bmp、gif、或 svg .‘, 43     ‘in‘                   => ‘参数 :attribute 必须包含在给定的值列表【:values】中.‘, 44     ‘in_array‘             => ‘参数 :attribute 必须存在于 :other值中.‘, 45     ‘integer‘              => ‘参数 :attribute 必须是整数.‘, 46     ‘ip‘                   => ‘参数 :attribute 必须是 IP 地址.‘, 47     ‘ipv4‘                 => ‘参数 :attribute 必须是 IPv4 地址.‘, 48     ‘ipv6‘                 => ‘参数 :attribute 必须是 IPv6 地址.‘, 49     ‘json‘                 => ‘参数 :attribute 必须是有效的 JSON 字符串.‘, 50     ‘lt‘                   => [
 51         ‘numeric‘ => ‘The :attribute 必须小于 :value.‘, 52         ‘file‘    => ‘The :attribute 必须小于 :value KB.‘, 53         ‘string‘  => ‘The :attribute 必须小于 :value 字符.‘, 54         ‘array‘   => ‘The :attribute 必须小于 :value 项.‘, 55     ], 56     ‘lte‘                  => [
 57         ‘numeric‘ => ‘The :attribute 必须小于或等于 :value.‘, 58         ‘file‘    => ‘The :attribute 必须小于或等于 :value KB.‘, 59         ‘string‘  => ‘The :attribute 必须小于或等于 :value 字符.‘, 60         ‘array‘   => ‘The :attribute 必须小于或等于 :value 项.‘, 61     ], 62     ‘max‘                  => [
 63         ‘numeric‘ => ‘:attribute 的最大长度为 :max 位‘, 64         ‘file‘    => ‘:attribute 的最大为 :max‘, 65         ‘string‘  => ‘:attribute 的最大长度为 :max 字符‘, 66         ‘array‘   => ‘:attribute 的最大个数为 :max 个‘, 67     ], 68     ‘mimes‘                => ‘参数 :attribute 的文件类型必须是:values.‘, 69     ‘mimetypes‘            => ‘参数 :attribute 的文件类型必须是:values.‘, 70     ‘min‘                  => [
 71         ‘numeric‘ => ‘:attribute 的最小长度为 :min 位‘, 72         ‘file‘    => ‘:attribute 大小至少为:min KB‘, 73         ‘string‘  => ‘:attribute 的最小长度为 :min 字符‘, 74         ‘array‘   => ‘:attribute 至少有 :min 项‘, 75     ], 76     ‘not_in‘               => ‘参数 :attribute 不能包含在给定的值列表【:values】中.‘, 77     ‘not_regex‘            => ‘参数 :attribute format is invalid.‘, 78     ‘numeric‘              => ‘参数 :attribute 必须是数字.‘, 79     ‘present‘              => ‘验证的字段:attribute必须存在于输入数据中,但可以为空.‘, 80     ‘regex‘                => ‘验证的字段 :attribute 必须与给定的正则表达式匹配.‘, 81required‘             => ‘参数 :attribute 必须存在于输入数据中,而不是空.‘, 82required_if‘          => ‘当指定的字段:other 等于任何一个 value 时,被验证的字段:attribute必须存在且不为空.‘, 83required_unless‘      => ‘当指定的字段:other等于任何一个 :values 时,被验证的字段:attribute 不必存在.‘, 84required_with‘        => ‘只要在指定的其他字段中:values有任意一个字段存在时,被验证的字段:attribute就必须存在并且不能为空.‘, 85required_with_all‘    => ‘只有当所有的其他指定字段:values全部存在时,被验证的字段:attribute才必须存在并且不能为空.‘, 86required_without‘     => ‘只要在其他指定的字段中:values有任意一个字段不存在,被验证的字段:attribute就必须存在且不为空.‘, 87required_without_all‘ => ‘只有当所有的其他指定的字段:values都不存在时,被验证的参数 :attribute 才必须存在且不为空.‘, 88     ‘same‘                 => ‘参数 :attribute 和 :other 必须匹配.‘, 89     ‘size‘                 => [
 90         ‘numeric‘ => ‘参数 :attribute 必须是 :size 位.‘, 91         ‘file‘    => ‘参数 :attribute 必须是 :size KB.‘, 92         ‘string‘  => ‘参数 :attribute 必须是 :size 个字符.‘, 93         ‘array‘   => ‘参数 :attribute 必须包括 :size 项.‘, 94     ], 95     ‘string‘               => ‘参数 :attribute 必须是字符串.‘, 96     ‘timezone‘             => ‘参数 :attribute 必须个有效的时区.‘, 97     ‘unique‘               => ‘参数 :attribute 已存在.‘, 98     ‘uploaded‘             => ‘参数 :attribute 上传失败.‘, 99     ‘url‘                  => ‘参数 :attribute 必须是有效的 URL.‘,100     ‘mb_max‘                  => ‘参数 :attribute 必须是 :mb_max 字符以内.‘,101     ‘phone‘                  => ‘参数 :attribute 手机号码不合法‘,

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐