LoginSignup
1
0

[Laravel]nullが入る可能性のあるカスタムバリデーションを作成する場合

Posted at

備忘記

  • カスタムのバリデーションRuleを作成したときにnullの値のものがRuleを通ってないことが発覚。
  • その解決策を記載します。

前提

Laravel Framework 10.46.0
PHP 8.3.1

方法

コマンドはこれ!

 php artisan make:rule Uppercase --implicit

もし無しで作成しちゃったら、、、?

class Uppercase implements DataAwareRule, ValidationRule
{
    # ここの部分を追加する
    /**
     * Indicates whether the rule should be implicit.
     *
     * @var bool
     */
    public $implicit = true;

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0