Files
Business-credit-asistant/app/Rules/PasswordValidationRule.php
2026-06-29 13:00:18 +06:00

57 lines
1.5 KiB
PHP

<?php
namespace App\Rules;
use Illuminate\Contracts\Validation\Rule;
class PasswordValidationRule implements Rule
{
protected string $password_validation_rule = '/^(?=[-a-zA-Z0-9!@_*.]*$).*/';
protected string $identity_iq_password_validation_rule = '/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[a-zA-Z]).{8,}$/'; // identity iq
/**
* Create a new rule instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Determine if the validation rule passes.
*
* @param string $attribute
* @param mixed $value
* @return bool
*/
public function passes($attribute, $value)
{
$inputData = request()->all();
$source_type = '';
if(!empty($inputData['creditreport'])){
$source_type = $inputData['creditreport']['credit_report_company_type'];
}if(!empty($inputData['source_type'])){
$source_type = $inputData['source_type'];
}
if($source_type == config('constant.reportType.SMART_CREDIT'))
{
return preg_match($this->password_validation_rule,$value);
}
elseif ($source_type == config('constant.reportType.IDENTITY_IQ')){
return preg_match($this->identity_iq_password_validation_rule,$value);
}
}
/**
* Get the validation error message.
*
* @return string
*/
public function message()
{
return 'Password must be 8 characters and include a capital, lowercase, number and symbol.';
}
}