| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentCart\Api\Validator; |
| 4 |
|
| 5 |
use FluentCart\Framework\Response\Response; |
| 6 |
use FluentCart\Framework\Validator\Validator; |
| 7 |
|
| 8 |
abstract class Validation |
| 9 |
{ |
| 10 |
public static function validate($data, $rules = []) |
| 11 |
{ |
| 12 |
$validator = (new Validator())->make($data, empty($rules) ? static::rules() : $rules); |
| 13 |
|
| 14 |
if($validator->validate()->fails()) { |
| 15 |
$response = new Response(); |
| 16 |
return $response->json(['errors' => $validator->errors()], 403); |
| 17 |
} |
| 18 |
|
| 19 |
return false; |
| 20 |
} |
| 21 |
} |
| 22 |
|