Laravel 5.1 Modify input before form request validation

后端 未结 5 956
感情败类
感情败类 2020-12-20 21:05

Is there a way to modify input fields inside a form request class before the validation takes place?

I want to modify some input date fields as follows but it doesn

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-20 21:35

    The FormRequest has a method validationData() that return the data to validate, so i'm overriding it in my form request:

    all(),
                [
                    'number' => preg_replace("/[^0-9]/", "", $this->number)
                ]
            );
        }
        ...
    }
    

    It work fine i'm using Laravel 5.4 :)

提交回复
热议问题