驗證裡,PHP 檔案中指定自定義值

cyyyrcyx發表於2020-04-21

在 PHP 檔案中指定自定義值
有時您可能需要將驗證資訊的 :value 替換為自定義的表示形式。例如,指定 payment_type 的值為 cc :

$request->validate([
‘credit_card_number’ => ‘required_if:payment_type,cc’
]);
如果此驗證規則失敗,將生成以下錯誤資訊:

The credit card number field is required when payment type is cc.

————————————————
上面的required_if:payment_type,cc表示:當payment_type欄位值為cc時,credit_card_number欄位必須

本作品採用《CC 協議》,轉載必須註明作者和本文連結

相關文章