Makes no sense.........
modified the sanitize function like:
public function sanitize()
{
$input = $this->all(); //trying both since neither seem to do anything
Request::all();
$input['title'] = trim(strtolower($input['title']));
Request::replace($input); //LOG SHOWS ZERO CHANGES
$this->replace($input);
Log::info(Request::all());
}
I have a rule on title
return [
'title' => 'required|min:5|max:50'
];
Go to the form and in title field enter => D [spacebar][spacebar][spacebar][spacebar][spacebar] X and it validates even with only 2 characters, its not doing anything to the data.......
Tried Input::all() Input::replace() merge,
Please help, I have tried just about everything.
If this helps anyone or can be improved please let me know, I will move it to the request.php so it can run on all requests.
Removes all whitespace in a string and also before and after.
So input like => [space] [space] [space] H [space] EL [space] [space] [space] [space] LO H EL LO
Will return HELLO before validation
public function all()
{
$input = parent::all();
$whitespace = create_function('&$value, &$key','$key; $value = trim(preg_replace("/\s+/", " " ,$value));');
array_walk_recursive($input,$whitespace);
return $input;
}
Only problem so far is Laravel validation counts spaces as valid characters so min:5 does not really mean 5 characters since passing=> a b c (you see 3 characters but it gets counted as 5 with the space) will pass validation
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community