I have a form which holds a url
input and I need to validate that the given URL is not blacklisted by a 3rd party API, i'm not sure if I need to use a Middleware
or create a specific form Request
and verify that URL before passing on that request to a command. Any ideas?
It's a job for Validator. Add your custom rule before validation:
Validator::extend('custom', function($attribute, $value, $parameters)
{
// make 3rd party request using $value
if (…) {
return true;
} else {
return false;
}
});
Don't forget to add error message string to resourses/lang/xx/validation.php
file.
Read more: http://laravel.com/docs/5.0/validation#custom-validation-rules
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With