Ajoute la vue d'erreur et un validateur
This commit is contained in:
41
src/Silex/Validation/UserValidation.php
Normal file
41
src/Silex/Validation/UserValidation.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Silex\Validation;
|
||||
|
||||
final class UserValidation
|
||||
{
|
||||
public static function isValidLogin(array &$post, array &$errors): bool
|
||||
{
|
||||
if(empty($post['login'])) {
|
||||
$errors[] = 'Login error';
|
||||
}
|
||||
|
||||
if(empty($post['password'])) {
|
||||
$errors[] = 'Password error';
|
||||
}
|
||||
return empty($errors);
|
||||
}
|
||||
|
||||
public static function isValidUser(array &$post, array &$errors): bool
|
||||
{
|
||||
if(empty($post['login'])) {
|
||||
$errors[] = 'Login empty error';
|
||||
}
|
||||
|
||||
if(empty($post['password'])) {
|
||||
$errors[] = 'Password empty error';
|
||||
}
|
||||
|
||||
if(empty($post['password-confirmation'])) {
|
||||
$errors[] = 'Password confirmation empty error';
|
||||
}
|
||||
|
||||
if($post['password'] !== $post['password-confirmation']){
|
||||
$errors[] = 'Password confirmation not matching error';
|
||||
}
|
||||
|
||||
return empty($errors);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user