Laravel中validation驗(yàn)證 返回中文提示 全局設(shè)置的方法
更改 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必須是一個(gè)合法的 URL', 'after' => ':attribute 必須是 :date 之后的一個(gè)日期', 'after_or_equal' => ':attribute 必須是 :date 之后或相同的一個(gè)日期', 'alpha' => ':attribute只能包含字母', 'alpha_dash' => ':attribute只能包含字母、數(shù)字、中劃線或下劃線', 'alpha_num' => ':attribute只能包含字母和數(shù)字', 'array' => ':attribute必須是一個(gè)數(shù)組', 'before' => ':attribute 必須是 :date 之前的一個(gè)日期', 'before_or_equal' => ':attribute 必須是 :date 之前或相同的一個(gè)日期', 'between' => [ 'numeric' => ':attribute 必須在 :min 到 :max 之間', 'file' => ':attribute 必須在 :min 到 :max KB 之間', 'string' => ':attribute 必須在 :min 到 :max 個(gè)字符之間', 'array' => ':attribute 必須在 :min 到 :max 項(xiàng)之間', ], 'boolean' =>':attribute字符必須是 true 或false, 1 或 0 ', 'confirmed' => ':attribute 二次確認(rèn)不匹配', 'date' => ':attribute 必須是一個(gè)合法的日期', 'date_format' => ':attribute 與給定的格式 :format 不符合', 'different' => ':attribute 必須不同于 :other', 'digits' => ':attribute必須是 :digits 位.', 'digits_between' => ':attribute 必須在 :min 和 :max 位之間', 'dimensions' => ':attribute具有無(wú)效的圖片尺寸', 'distinct' => ':attribute字段具有重復(fù)值', 'email' => ':attribute必須是一個(gè)合法的電子郵件地址', 'exists' => '選定的 :attribute 是無(wú)效的.', 'file' => ':attribute必須是一個(gè)文件', 'filled' => ':attribute的字段是必填的', 'image' => ':attribute必須是 jpeg, png, bmp 或者 gif 格式的圖片', 'in' => '選定的 :attribute 是無(wú)效的', 'in_array' => ':attribute 字段不存在于 :other', 'integer' => ':attribute 必須是個(gè)整數(shù)', 'ip' => ':attribute必須是一個(gè)合法的 IP 地址。', 'json' => ':attribute必須是一個(gè)合法的 JSON 字符串', 'max' => [ 'numeric' => ':attribute 的最大長(zhǎng)度為 :max 位', 'file' => ':attribute 的最大為 :max', 'string' => ':attribute 的最大長(zhǎng)度為 :max 字符', 'array' => ':attribute 的最大個(gè)數(shù)為 :max 個(gè).', ], 'mimes' => ':attribute 的文件類(lèi)型必須是 :values', 'min' => [ 'numeric' => ':attribute 的最小長(zhǎng)度為 :min 位', 'file' => ':attribute 大小至少為 :min KB', 'string' => ':attribute 的最小長(zhǎng)度為 :min 字符', 'array' => ':attribute 至少有 :min 項(xiàng)', ], 'not_in' => '選定的 :attribute 是無(wú)效的', 'numeric' => ':attribute 必須是數(shù)字', 'present' => ':attribute 字段必須存在', 'regex' => ':attribute 格式是無(wú)效的', 'required' => ':attribute 字段是必須的', 'required_if' => ':attribute 字段是必須的當(dāng) :other 是 :value', 'required_unless' => ':attribute 字段是必須的,除非 :other 是在 :values 中', 'required_with' => ':attribute 字段是必須的當(dāng) :values 是存在的', 'required_with_all' => ':attribute 字段是必須的當(dāng) :values 是存在的', 'required_without' => ':attribute 字段是必須的當(dāng) :values 是不存在的', 'required_without_all' => ':attribute 字段是必須的當(dāng) 沒(méi)有一個(gè) :values 是存在的', 'same' => ':attribute和:other必須匹配', 'size' => [ 'numeric' => ':attribute 必須是 :size 位', 'file' => ':attribute 必須是 :size KB', 'string' => ':attribute 必須是 :size 個(gè)字符', 'array' => ':attribute 必須包括 :size 項(xiàng)', ], 'string' => ':attribute 必須是一個(gè)字符串', 'timezone' => ':attribute 必須是個(gè)有效的時(shí)區(qū).', 'unique' => ':attribute 已存在', 'url' => ':attribute 無(wú)效的格式', /* |-------------------------------------------------------------------------- | 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驗(yàn)證 返回中文提示 全局設(shè)置的方法就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
Laravel 5.1 框架Blade模板引擎用法實(shí)例分析
這篇文章主要介紹了Laravel 5.1 框架Blade模板引擎用法,結(jié)合實(shí)例形式分析了laravel5.1框架Blade模板引擎基本功能、創(chuàng)建、使用方法及相關(guān)操作注意事項(xiàng),需要的朋友可以參考下2020-01-01Yii Framework框架獲取分類(lèi)下面的所有子類(lèi)方法
Yii是一個(gè)基于組件、用于開(kāi)發(fā)大型 Web 應(yīng)用的 高性能 PHP 框架。Yii 幾乎擁有了 所有的特性 ,包括 MVC、DAO/ActiveRecord、I18N/L10N、caching、基于 JQuery 的 AJAX 支持、用戶認(rèn)證和基于角色的訪問(wèn)控制、腳手架、輸入驗(yàn)證、部件、事件、主題化以及 Web 服務(wù)等等。2014-06-06laravel Model 執(zhí)行事務(wù)的實(shí)現(xiàn)
今天小編就為大家分享一篇laravel Model 執(zhí)行事務(wù)的實(shí)現(xiàn),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-10-10Thinkphp 在api開(kāi)發(fā)中異常返回依然是html的解決方式
今天小編就為大家整理了一篇Thinkphp 在api開(kāi)發(fā)中異常返回依然是html的解決方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-10-10ThinkPHP實(shí)現(xiàn)支付寶接口功能實(shí)例
這篇文章主要介紹了ThinkPHP實(shí)現(xiàn)支付寶接口功能的方法,實(shí)例講述了支付寶接口的下載及二次開(kāi)發(fā)方法,以及對(duì)應(yīng)的ThinkPHP開(kāi)發(fā)技巧,需要的朋友可以參考下2014-12-12PHP實(shí)現(xiàn)多條件查詢實(shí)例代碼
在我們的網(wǎng)站設(shè)計(jì)過(guò)程中,經(jīng)常會(huì)用到多條件查詢,本文的源碼是一個(gè)二手房屋查詢的例子。在本例中,我們要實(shí)現(xiàn)能夠通過(guò)地理位置,物業(yè)類(lèi)型,房屋價(jià)格,房屋面積及信息發(fā)布日期等多個(gè)條件查詢到客戶所需的資料。2010-07-07使用ob系列函數(shù)實(shí)現(xiàn)PHP網(wǎng)站頁(yè)面靜態(tài)化
php頁(yè)面緩存主要用到的是ob系列函數(shù),如ob_start(),ob_end_flush(),ob_get_contents() ,今天我們來(lái)談?wù)勈褂眠@些函數(shù)來(lái)實(shí)現(xiàn)php網(wǎng)站頁(yè)面靜態(tài)化2014-08-08