parent
4a59f41859
commit
8118cfe188
@ -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);
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
<?php if ($params['errors']) :
|
||||
foreach ($params['errors'] as $error) { ?>
|
||||
<article class="message is-danger">
|
||||
<div class="message-header">
|
||||
<p>Auth failed</p>
|
||||
</div>
|
||||
<div class="message-body">
|
||||
<?= $error?>
|
||||
</div>
|
||||
</article>
|
||||
<?php } endif ?>
|
Loading…
Reference in new issue