-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add: validation errors and messages Improve: Controllers with requests Tests
- Loading branch information
1 parent
f742250
commit d8815a6
Showing
13 changed files
with
335 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Http\Requests\Auth; | ||
|
||
use Illuminate\Contracts\Validation\ValidationRule; | ||
use Illuminate\Foundation\Http\FormRequest; | ||
|
||
class AuthenticateSessionRequest extends FormRequest | ||
{ | ||
public function authorize(): bool | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* @return array<string, ValidationRule|array|string> | ||
*/ | ||
public function rules(): array | ||
{ | ||
return [ | ||
"email" => "required|email|max:255", | ||
"password" => "required|string", | ||
]; | ||
} | ||
|
||
public function messages(): array | ||
{ | ||
return [ | ||
"email" => [ | ||
"required" => "The email field is required.", | ||
"max" => "Your email is too long. It must not be greater than 255 characters.", | ||
"unique" => "The email has already been taken.", | ||
"email" => "Your email is invalid.", | ||
], | ||
|
||
"password" => [ | ||
"required" => "The password field is required.", | ||
], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Http\Requests\Auth; | ||
|
||
use Illuminate\Contracts\Validation\ValidationRule; | ||
use Illuminate\Foundation\Http\FormRequest; | ||
|
||
class ForgotPasswordRequest extends FormRequest | ||
{ | ||
public function authorize(): bool | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* @return array<string, ValidationRule|array|string> | ||
*/ | ||
public function rules(): array | ||
{ | ||
return [ | ||
"email" => "required|string|email:dns|max:255", | ||
]; | ||
} | ||
|
||
public function messages(): array | ||
{ | ||
return [ | ||
"email" => [ | ||
"required" => "The email field is required.", | ||
"max" => "Your email is too long. It must not be greater than 255 characters.", | ||
"email" => "Your email is invalid.", | ||
], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Http\Requests\Auth; | ||
|
||
use Illuminate\Contracts\Validation\ValidationRule; | ||
use Illuminate\Foundation\Http\FormRequest; | ||
|
||
class ResetPasswordRequest extends FormRequest | ||
{ | ||
public function authorize(): bool | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* @return array<string, ValidationRule|array|string> | ||
*/ | ||
public function rules(): array | ||
{ | ||
return [ | ||
"token" => "required", | ||
"email" => "required|email|max:255", | ||
"password" => "required|min:8|confirmed:password_confirmation", | ||
]; | ||
} | ||
|
||
public function messages(): array | ||
{ | ||
return [ | ||
"token" => [ | ||
"required" => "The token field is required.", | ||
], | ||
"email" => [ | ||
"required" => "The email field is required.", | ||
"max" => "Your email is too long. It must not be greater than 255 characters.", | ||
"email" => "Your email is invalid.", | ||
], | ||
"password" => [ | ||
"required" => "The password field is required.", | ||
"min" => "Your password is too short. It must be at least 8 characters.", | ||
"confirmed" => "The password field confirmation does not match.", | ||
], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.