<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                ## 可用的驗證規則 以下是所有可用的驗證規則清單與功能: * [Accepted](https://learnku.com/docs/lumen/5.1/validation/1852#rule-accepted) * [Active URL](https://learnku.com/docs/lumen/5.1/validation/1852#rule-active-url) * [After (Date)](https://learnku.com/docs/lumen/5.1/validation/1852#rule-after) * [Alpha](https://learnku.com/docs/lumen/5.1/validation/1852#rule-alpha) * [Alpha Dash](https://learnku.com/docs/lumen/5.1/validation/1852#rule-alpha-dash) * [Alpha Numeric](https://learnku.com/docs/lumen/5.1/validation/1852#rule-alpha-num) * [Array](https://learnku.com/docs/lumen/5.1/validation/1852#rule-array) * [Before (Date)](https://learnku.com/docs/lumen/5.1/validation/1852#rule-before) * [Between](https://learnku.com/docs/lumen/5.1/validation/1852#rule-between) * [Boolean](https://learnku.com/docs/lumen/5.1/validation/1852#rule-boolean) * [Confirmed](https://learnku.com/docs/lumen/5.1/validation/1852#rule-confirmed) * [Date](https://learnku.com/docs/lumen/5.1/validation/1852#rule-date) * [Date Format](https://learnku.com/docs/lumen/5.1/validation/1852#rule-date-format) * [Different](https://learnku.com/docs/lumen/5.1/validation/1852#rule-different) * [Digits](https://learnku.com/docs/lumen/5.1/validation/1852#rule-digits) * [Digits Between](https://learnku.com/docs/lumen/5.1/validation/1852#rule-digits-between) * [E-Mail](https://learnku.com/docs/lumen/5.1/validation/1852#rule-email) * [Exists (Database)](https://learnku.com/docs/lumen/5.1/validation/1852#rule-exists) * [Image (File)](https://learnku.com/docs/lumen/5.1/validation/1852#rule-image) * [In](https://learnku.com/docs/lumen/5.1/validation/1852#rule-in) * [Integer](https://learnku.com/docs/lumen/5.1/validation/1852#rule-integer) * [IP Address](https://learnku.com/docs/lumen/5.1/validation/1852#rule-ip) * [Max](https://learnku.com/docs/lumen/5.1/validation/1852#rule-max) * [MIME Types (File)](https://learnku.com/docs/lumen/5.1/validation/1852#rule-mimes) * [Min](https://learnku.com/docs/lumen/5.1/validation/1852#rule-min) * [Not In](https://learnku.com/docs/lumen/5.1/validation/1852#rule-not-in) * [Numeric](https://learnku.com/docs/lumen/5.1/validation/1852#rule-numeric) * [Regular Expression](https://learnku.com/docs/lumen/5.1/validation/1852#rule-regex) * [Required](https://learnku.com/docs/lumen/5.1/validation/1852#rule-required) * [Required If](https://learnku.com/docs/lumen/5.1/validation/1852#rule-required-if) * [Required With](https://learnku.com/docs/lumen/5.1/validation/1852#rule-required-with) * [Required With All](https://learnku.com/docs/lumen/5.1/validation/1852#rule-required-with-all) * [Required Without](https://learnku.com/docs/lumen/5.1/validation/1852#rule-required-without) * [Required Without All](https://learnku.com/docs/lumen/5.1/validation/1852#rule-required-without-all) * [Same](https://learnku.com/docs/lumen/5.1/validation/1852#rule-same) * [Size](https://learnku.com/docs/lumen/5.1/validation/1852#rule-size) * [String](https://learnku.com/docs/lumen/5.1/validation/1852#rule-string) * [Timezone](https://learnku.com/docs/lumen/5.1/validation/1852#rule-timezone) * [Unique (Database)](https://learnku.com/docs/lumen/5.1/validation/1852#rule-unique) * [URL](https://learnku.com/docs/lumen/5.1/validation/1852#rule-url) #### accepted 驗證字段值是否為*yes*、*on*、*1*、或*true*。這在確認「服務條款」是否同意時相當有用。 #### active\_url 驗證字段值是否為一個有效的網址,會通過 PHP 的`checkdnsrr`函數來驗證。 #### after:*date* 驗證字段是否是在指定日期之后。這個日期將會通過`strtotime`函數來驗證。 ~~~php 'start_date' => 'required|date|after:tomorrow' ~~~ 作為替換`strtotime`傳遞的日期字符串,你可以指定其它的字段來比較日期: ~~~php 'finish_date' => 'required|date|after:start_date' ~~~ #### alpha 驗證字段值是否僅包含字母字符。 #### alpha\_dash 驗證字段值是否僅包含字母、數字、破折號( - )以及下劃線( \_ )。 #### alpha\_num 驗證字段值是否僅包含字母、數字。 #### array 驗證字段必須是一個 PHP`array`。 #### before:*date* 驗證字段是否是在指定日期之前。這個日期將會使用 PHP`strtotime`函數來驗證。 #### between:*min*,*max* 驗證字段值的大小是否介于指定的*min*和*max*之間。字符串、數值或是文件大小的計算方式和[`size`](https://learnku.com/docs/lumen/5.1/validation/1852#rule-size)規則相同。 #### boolean 驗證字段值是否能夠轉換為布爾值。可接受的參數為`true`、`false`、`1`、`0`、`"1"`以及`"0"`。 #### confirmed 驗證字段值必須和`foo_confirmation`的字段值一致。例如,如果要驗證的字段是`password`,就必須和輸入數據里的`password_confirmation`的值保持一致。 #### date 驗證字段值是否為有效日期,會根據 PHP 的`strtotime`函數來做驗證。 #### date\_format:*format* 驗證字段值符合定義的日期*格式*,通過 PHP 的`date_parse_from_format`函數來驗證。 #### different:*field* 驗證字段值是否和指定\_字段( field )\_不同。 #### digits:*value* 驗證字段值是否為*numeric*且長度為*value*。 #### digits\_between:*min*,*max* 驗證字段值的長度是否在*min*和*max*之間。 #### email 驗證字段值是否符合 e-mail 格式。 #### exists:*table*,*column* 驗證字段值是否存在指定的數據表中。 #### Exists 規則的基本使用方法 ~~~php 'state' => 'exists:states' ~~~ #### 指定一個特定的字段名稱 ~~~php 'state' => 'exists:states,abbreviation' ~~~ 也可以指定更多的條件,它們會被加到「where」查詢語句中: ~~~php 'email' => 'exists:staff,email,account_id,1' ~~~ 你也可以傳遞`NULL`或`NOT_NULL`至「where」語句: ~~~php 'email' => 'exists:staff,email,deleted_at,NULL' 'email' => 'exists:staff,email,deleted_at,NOT_NULL' ~~~ #### image 驗證字段文件必須為圖片格式( jpeg、png、bmp、gif、 或 svg )。 #### in:*foo*,*bar*,... 驗證字段值是否有在指定的列表里面。 #### integer 驗證字段值是否是整數。 #### ip 驗證字段值是否符合 IP address 的格式。 #### json 驗證字段是否是一個有效的 JSON 字符串。 #### max:*value* 字段值必須小于或等于*value*。字符串、數值或是文件大小的計算方式和[`size`](https://learnku.com/docs/lumen/5.1/validation/1852#rule-size)規則相同。 #### mimes:*foo*,*bar*,... 驗證字段文件的 MIME 類型是否符合列表中指定的格式。 #### MIME 規則基本用法 ~~~php 'photo' => 'mimes:jpeg,bmp,png' ~~~ 即使你可能只需要驗證指定擴展名,但此規則實際上會驗證文件的 MIME 類型,其通過讀取文件的內容以猜測它的 MIME 類型。 完整的 MIME 類型及對應的擴展名列表可以在下方鏈接找到:[svn.apache.org/repos/asf/httpd/http...](http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types) #### min:*value* 字段值必須大于或等于*value*。字符串、數值或是文件大小的計算方式和[`size`](https://learnku.com/docs/lumen/5.1/validation/1852#rule-size)規則相同。 #### not\_in:*foo*,*bar*,... 驗證字段值是否不在指定的列表里。 #### numeric 驗證字段值是否為數值。 #### regex:*pattern* 驗證字段值是否符合指定的正則表達式。 \*\*注意:\*\*當使用`regex`規則時,你必須使用數組,而不是使用管道分隔規則,特別是當正則表達式含有管道符號時。 #### required 驗證字段必須存在輸入數據,且不為空。字段符合下方任一條件時即為「空」: * 該值為`null`。 * 該值為空字符串。 * 該值為空數組或空的`可數`對象。 * 該值為沒有路徑的上傳文件。 #### required\_if:*anotherfield*,*value*,... 如果指定的*其它字段*( anotherfield )等于任何一個*value*時,此字段為必填。 #### required\_unless:*anotherfield*,*value*,... 如果指定的*其它字段*( anotherfield )等于任何一個*value*時,則此字段為不必填。 #### required\_with:*foo*,*bar*,... 如果指定的字段中的*任意一個*有值,則此字段為必填。 #### required\_with\_all:*foo*,*bar*,... 如果指定的*所有*字段都有值,則此字段為必填。 #### required\_without:*foo*,*bar*,... 如果缺少任意一個指定的字段,則此字段為必填。 #### required\_without\_all:*foo*,*bar*,... 如果所有指定的字段都沒有值,則此字段為必填。 #### same:*field* 驗證字段值和指定的\*字段( field )\*值是否相同。 #### size:*value* 驗證字段值的大小是否符合指定的*value*值。對于字符串來說,*value*為字符數。對于數字來說,*value*為某個整數值。對文件來說,*size*對應的是文件大小(單位 kb )。 #### string 驗證字段值的類型是否為字符串。 #### timezone 驗證字段值是否是有效的時區,會根據 PHP 的`timezone_identifiers_list`函數來判斷。 #### unique:*table*,*column*,*except*,*idColumn* 在指定的數據表中,驗證字段必須是唯一的。如果沒有指定`column`,將會使用字段本身的名稱。 **指定一個特定的字段名稱:** ~~~php 'email' => 'unique:users,email_address' ~~~ **自定義數據庫連接** 有時候你可能需要自定義一個連接,來通過 Validator 對數據庫進行查找。如上面所示,設置`unique:users`作為驗證規則,通過默認數據庫連接來做數據庫查找。如果要重寫驗證規則,可在指定的連接的表單名稱后面加上「.」: ~~~php 'email' => 'unique:connection.users,email_address' ~~~ **強迫 Unique 規則忽略指定 ID:** 有時候,你希望在驗證字段時對指定 ID 進行忽略。例如,在「更新個人資料」頁面會包含用戶名、郵箱等字段。這時你會想要驗證更新的 e-mail 值是否為唯一的。如果用戶僅更改了名稱字段而不是 e-mail 字段,就不需要拋出驗證錯誤,因為此用戶已經是這個 e-mail 的擁有者了。假設用戶提供的 e-mail 已經被其他用戶使用,則需要拋出驗證錯誤。若要用指定規則來忽略用戶 ID,則應該把要發送的 ID 當作第三個參數: ~~~php 'email' => 'unique:users,email_address,'.$user->id ~~~ 如果你的數據表使用的主鍵名稱不是`id`,那么你可以在第四個參數中來指定它: ~~~php 'email' => 'unique:users,email_address,'.$user->id.',user_id' ~~~ **增加額外的 Where 語句:** 你也可以指定更多的條件到「where」查詢語句: ~~~php 'email' => 'unique:users,email_address,NULL,id,account_id,1' ~~~ 上述規則中,只有`account_id`為`1`的數據列會被包含在 unique 規則的驗證。 #### url 根據 PHP 的`filter_var`函數來驗證字段是否符合 URL 格式。 ## 按條件增加規則 在某些情況下,你可能**只想**在輸入數據中有此字段時才進行驗證。可通過增加`sometimes`規則到規則列表來實現: ~~~php $v = Validator::make($data, [ 'email' => 'sometimes|required|email', ]); ~~~ 在上面的例子中,`email`字段的驗證只會在`$data`數組有此字段時才會進行。 #### 復雜的條件驗證 有時候你可能希望增加更復雜的驗證條件,例如,你可以希望某個指定字段在另一個字段的值超過 100 時才為必填。或者當某個指定字段有值時,另外兩個字段要擁有符合的特定值。增加這樣的驗證條件并不難。首先,利用你熟悉的*static rules*來創建一個`Validator`實例: ~~~php $v = Validator::make($data, [ 'email' => 'required|email', 'games' => 'required|numeric', ]); ~~~ 假設我們有一個專為游戲收藏家所設計的網頁應用程序。如果游戲收藏家收藏超過一百款游戲,我們會希望他們來說明下為什么他們會擁有這么多游戲。比如說他們有可能經營了一家二手游戲商店,或者只是為了享受收集的樂趣。為了在特定條件下加入此驗證需求,可以在`Validator`實例中使用`sometimes`方法。 ~~~php $v->sometimes('reason', 'required|max:500', function($input) { return $input->games >= 100; }); ~~~ 傳入`sometimes`方法的第一個參數是我們要用條件認證的字段名稱。第二個參數是我們想使用的驗證規則。`閉包`作為第三個參數傳入,如果其返回`true`,則額外的規則就會被加入。這個方法可以輕松的創建復雜的條件式驗證。你甚至可以一次對多個字段增加條件式驗證: ~~~php $v->sometimes(['reason', 'cost'], 'required', function($input) { return $input->games >= 100; }); ~~~ > \*\*注意:\*\*傳入`閉包`的`$input`參數是`Illuminate\Support\Fluent`實例,可用來訪問你的輸入或文件對象。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看