2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[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;

2
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
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?