@@ -25,7 +25,7 @@ |
||
| 25 | 25 | */ |
| 26 | 26 | public function register() |
| 27 | 27 | {
|
| 28 | - $this->app->singleton('Cals\Validator\AjaxValidator', function () {
|
|
| 28 | + $this->app->singleton('Cals\Validator\AjaxValidator', function() {
|
|
| 29 | 29 | return new AjaxValidator(); |
| 30 | 30 | }); |
| 31 | 31 | } |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | class AjaxValidator |
| 15 | 15 | {
|
| 16 | - public function validate(array $values = [], $resource, array $messages = [], $sometimes = false) |
|
| 16 | + public function validate(array $values = [ ], $resource, array $messages = [ ], $sometimes = false) |
|
| 17 | 17 | {
|
| 18 | 18 | $rules = $this->rules($resource); |
| 19 | 19 | $messages = $this->messages($messages); |
@@ -21,15 +21,15 @@ discard block |
||
| 21 | 21 | $validator = Validator::make($values, $rules, $messages, $attributes); |
| 22 | 22 | if ($sometimes) {
|
| 23 | 23 | $extraRules = $this->rules('sometimes' . $resource);
|
| 24 | - $validator->sometimes(array_keys($extraRules), $extraRules, function () use ($sometimes) {
|
|
| 24 | + $validator->sometimes(array_keys($extraRules), $extraRules, function() use ($sometimes) {
|
|
| 25 | 25 | return $sometimes; |
| 26 | 26 | }); |
| 27 | 27 | } |
| 28 | 28 | if ($validator->fails()) {
|
| 29 | 29 | (new JsonResponse()) |
| 30 | - ->header('Access-Control-Allow-Origin','*')
|
|
| 31 | - ->header('Access-Control-Allow-Methods','*')
|
|
| 32 | - ->setData(['status' => 'failed', 'code' => 422, 'message' => $validator->errors()]) |
|
| 30 | + ->header('Access-Control-Allow-Origin', '*')
|
|
| 31 | + ->header('Access-Control-Allow-Methods', '*')
|
|
| 32 | + ->setData([ 'status' => 'failed', 'code' => 422, 'message' => $validator->errors() ]) |
|
| 33 | 33 | ->send(); |
| 34 | 34 | exit(0); |
| 35 | 35 | } |