feat: name regex
This commit is contained in:
parent
87b614a094
commit
61cd857783
|
|
@ -28,7 +28,14 @@ class RegisterRequest extends FormRequest
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
|
||||||
'name' => ['required', 'string', 'max:255'],
|
'name' => [
|
||||||
|
'required',
|
||||||
|
'string',
|
||||||
|
'min:3',
|
||||||
|
'max:32',
|
||||||
|
'regex:/^[a-zA-Z0-9_.-]+$/',
|
||||||
|
'unique:users,name',
|
||||||
|
],
|
||||||
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
|
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
|
||||||
'password' => ['required', 'string', 'min:8'],
|
'password' => ['required', 'string', 'min:8'],
|
||||||
'avatar' => ['sometimes', 'nullable', 'image', 'max:2048'],
|
'avatar' => ['sometimes', 'nullable', 'image', 'max:2048'],
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ class UpdateUserRequest extends FormRequest
|
||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'name' => ['sometimes', 'string', 'max:255'],
|
|
||||||
'bio' => ['sometimes', 'nullable', 'string'],
|
'bio' => ['sometimes', 'nullable', 'string'],
|
||||||
'height' => ['sometimes', 'nullable', 'integer'],
|
'height' => ['sometimes', 'nullable', 'integer'],
|
||||||
'avatar' => ['sometimes', 'nullable', 'image', 'max:2048'],
|
'avatar' => ['sometimes', 'nullable', 'image', 'max:2048'],
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
$table->unique('name');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
$table->dropUnique(['name']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
Loading…
Reference in New Issue