2019-08-15 17:11:43 +12:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace SilverStripe\Security\Tests\MemberTest;
|
|
|
|
|
|
|
|
use SilverStripe\Dev\TestOnly;
|
2024-09-23 14:31:50 +12:00
|
|
|
use SilverStripe\Core\Validation\ValidationResult;
|
2024-10-02 14:38:21 +13:00
|
|
|
use SilverStripe\Security\Member;
|
|
|
|
use SilverStripe\Security\Validation\PasswordValidator;
|
2019-08-15 17:11:43 +12:00
|
|
|
|
|
|
|
class VerySpecificPasswordValidator extends PasswordValidator implements TestOnly
|
|
|
|
{
|
2024-10-02 14:38:21 +13:00
|
|
|
public function validate(string $password, Member $member): ValidationResult
|
2019-08-15 17:11:43 +12:00
|
|
|
{
|
|
|
|
$result = ValidationResult::create();
|
2022-04-14 13:12:59 +12:00
|
|
|
if (strlen($password ?? '') !== 17) {
|
2019-08-15 17:11:43 +12:00
|
|
|
$result->addError('Password must be 17 characters long');
|
|
|
|
}
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
}
|