I am trying to validate a phone number. First I strip the '-' out then I convert the inputed string to an integer. When I try to validate the integer I get an error that the input must be an integer. However, I just converted the string to and integer. Why am I getting this error and how do I fix it?
Here is my code
$request->val = str_replace('-', '', $request->val);
Log::debug($request->val);
Log::debug(gettype($request->val)); //outputs string
$request->val = intval($request->val);
Log::debug(gettype($request->val));//outputs integer
$this->validate($request, [
'val' => 'Integer|min:10|max:15'//Get an error must be interget
]);