I'am trying to validate a URL to make sure it doesn't contain localhost. I have done it using if-else and want to do it using custom validator. I am lost how it could be done by validator.
if((strpos($request->input('url'), 'localhost') !== false) ||
(strpos($request->input('url'), 'http://localhost') !== false) ||
(strpos($request->input('url'), 'https://localhost') !== false) ||
(strpos($request->input('url'), '127.0.0.1') !== false) ||
(strpos($request->input('url'), 'http://127.0.0.1') !== false) ||
(strpos($request->input('url'), 'http://127.0.0.1') !== false))
{
return response()->json([
'error_description' => 'Localhost in not allowed in URL'
], 403);
}