authService->check(); } /** * Get the validation rules that apply to the request. * * @return array|string> */ public function rules(): array { return array_merge(parent::rules(), [ 'picture' => [ 'required', function (string $attribute, mixed $value, \Closure $fail): void { $valuePath = match (true) { is_string($value) => $value, $value instanceof UploadedFile => $value->getPathname(), default => null }; if (is_string($valuePath)) { ToolboxHelper::validatePicture( $attribute, $valuePath, $fail, (object) [ 'minWidth' => 800, 'maxWidth' => 800, 'minHeight' => 800, 'maxHeight' => 800, ] ); } elseif ($value !== null) { $fail('Unexpected value for picture'); } }, ], ]); } }