Laravel 5 Validation Trim

后端 未结 8 923
梦谈多话
梦谈多话 2020-12-18 05:23

I am a beginner in Laravel 5.

How can I remove whitespaces in validator?? i have read the documentation but there is no validator for trim(remove whitespaces).

8条回答
  •  感情败类
    2020-12-18 05:49

    You can use the following code to trim all string input (as you might have arrays in the input)

        // trim all input
        Input::merge(array_map(function ($value) {
            if (is_string($value)) {
                return trim($value);
            } else {
                return $value;
            }
        }, Input::all()));
    

提交回复
热议问题