Is it possible to use Laravels validate function to validate an array, and if so how?
I'm not interested in validating input or a request, I just wanna use Laravels great validation syntax on a completely ordinary array.
Example
$arr = array(
'name' => 'David',
'year' => 1986,
'score' => 532
);
$this->validate($arr, [
'name' => 'required',
'year' => 'numeric',
'score' => 'required|numeric'
]);
This will throw an error
Argument 1 passed to App\Http\Controllers\Controller::validate() must be an instance of Illuminate\Http\Request
- Laravel version: 5.1
- PHP version: 7.1