[WIP] Order process

This commit is contained in:
Ludovic CANDELLIER
2022-07-03 22:38:08 +02:00
parent bcb3e15f33
commit 06cfb92757
60 changed files with 1146 additions and 295 deletions

59
app/Rules/Password.php Normal file
View File

@@ -0,0 +1,59 @@
<?php
namespace App\Rules;
use Illuminate\Contracts\Validation\Rule;
class Password implements Rule
{
private $length;
private $message;
/**
* Create a new rule instance.
*
* @return void
*/
public function __construct($length = 8)
{
$this->length = $length;
}
/**
* Determine if the validation rule passes.
*
* @param string $attribute
* @param mixed $value
* @return bool
*/
public function passes($attribute, $value)
{
$rules = [
'#.{'.$this->length.',}#' => 'boilerplate::password.rules.length',
'#[a-z]+#' => 'boilerplate::password.rules.letter',
'#[A-Z]+#' => 'boilerplate::password.rules.capital',
'#[0-9]+#' => 'boilerplate::password.rules.number',
'#[^A-Za-z0-9]+#' => 'boilerplate::password.rules.special',
];
foreach ($rules as $rule => $msg) {
if (! preg_match($rule, $value)) {
$this->message = __($msg, ['min' => $this->length]);
return false;
}
}
return true;
}
/**
* Get the validation error message.
*
* @return string
*/
public function message()
{
return $this->message;
}
}