File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed
Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change 1717use Hyperf \Utils \Context ;
1818use Hyperf \Validation \Contracts \Validation \Factory as ValidationFactory ;
1919use Hyperf \Validation \Contracts \Validation \ValidatesWhenResolved ;
20+ use Hyperf \Validation \UnauthorizedException ;
2021use Hyperf \Validation \ValidatesWhenResolvedTrait ;
2122use Hyperf \Validation \ValidationException ;
2223use Psr \Container \ContainerInterface ;
@@ -63,6 +64,14 @@ public function response(): ResponseInterface
6364 return $ response ->withStatus (422 );
6465 }
6566
67+ /**
68+ * Get the validated data from the request.
69+ */
70+ public function validated (): array
71+ {
72+ return $ this ->getValidatorInstance ()->validated ();
73+ }
74+
6675 /**
6776 * Get custom messages for validator errors.
6877 */
@@ -167,6 +176,6 @@ protected function passesAuthorization(): bool
167176 */
168177 protected function failedAuthorization ()
169178 {
170- // throw new AuthorizationException ('This action is unauthorized.');
179+ throw new UnauthorizedException ('This action is unauthorized. ' );
171180 }
172181}
Original file line number Diff line number Diff line change @@ -47,10 +47,8 @@ protected function prepareForValidation()
4747
4848 /**
4949 * Get the validator instance for the request.
50- *
51- * @return ValidatorInterface
5250 */
53- protected function getValidatorInstance ()
51+ protected function getValidatorInstance (): ValidatorInterface
5452 {
5553 return $ this ->validator ();
5654 }
You can’t perform that action at this time.
0 commit comments