Skip to content

Commit

Permalink
"Refactor code for better readability and tighten password validation…
Browse files Browse the repository at this point in the history
… rules"

In the MkCertCommand.php file, redundant import comments have been removed to improve code readability and maintainability. Imports definitions are now straightforward
  • Loading branch information
AuroraYolo committed Aug 25, 2023
1 parent 669d80c commit e3c0f28
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 34 deletions.
37 changes: 5 additions & 32 deletions app/Command/MkCertCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,13 @@

namespace App\Command;

use /*
* Annotation class for defining a Hyperf Command.
*
* @Annotation
* @Target({"CLASS"})
*/
Hyperf\Command\Annotation\Command;
use /*
* Class HyperfCommand
*
* Represents a command in the Hyperf framework.
*
* @package Hyperf\Command
*/
Hyperf\Command\Command as HyperfCommand;
use /*
* The ContainerInterface represents a dependency injection container.
*
* It provides a minimal set of methods to define and retrieve services.
*
* @link https://www.php-fig.org/psr/psr-11/
*/
Psr\Container\ContainerInterface;
use /*
* Class InputOption
*
* Represents a command line option.
*
* @package Symfony\Component\Console\Input
*/
Symfony\Component\Console\Input\InputOption;
use Hyperf\Command\Annotation\Command;
use Hyperf\Command\Command as HyperfCommand;
use Psr\Container\ContainerInterface;
use Symfony\Component\Console\Input\InputOption;

/**
* Class MkCertCommand
* Class MkCertCommand.
*
* This class represents a command for generating SSL certificates using the mkcert tool.
* The command can be invoked by running `php bin/hyperf.php mkcert:command`.
Expand Down
13 changes: 11 additions & 2 deletions app/Request/UserRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,20 @@ public function authorize(): bool
return true;
}

public function rules()
public function rules(): array
{
return [
'username' => 'required',
'password' => 'required',
'password' => 'required|regex:/^[A-Za-z0-9]+$/',
];
}

public function messages(): array
{
return [
'username.required' => '用户名必须填写!',
'password.required' => '密码必须填写!',
'password.regex' => '密码必须带有数字和字符串!',
];
}
}

0 comments on commit e3c0f28

Please sign in to comment.