Ajoute la vue d'erreur et un validateur

This commit is contained in:
Colin FRIZOT
2022-12-06 08:48:21 +01:00
parent 4a59f41859
commit 8118cfe188
5 changed files with 66 additions and 28 deletions

View 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);
}
}