vendor/symfony/validator/Constraints/NotCompromisedPassword.php line 25

  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <[email protected]>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Component\Validator\Constraints;
  11. use Symfony\Component\Validator\Constraint;
  12. /**
  13.  * Checks if a password has been leaked in a data breach.
  14.  *
  15.  * @Annotation
  16.  * @Target({"PROPERTY", "METHOD", "ANNOTATION"})
  17.  *
  18.  * @author Kévin Dunglas <[email protected]>
  19.  */
  20. #[\Attribute(\Attribute::TARGET_PROPERTY \Attribute::TARGET_METHOD \Attribute::IS_REPEATABLE)]
  21. class NotCompromisedPassword extends Constraint
  22. {
  23.     public const COMPROMISED_PASSWORD_ERROR 'd9bcdbfe-a9d6-4bfa-a8ff-da5fd93e0f6d';
  24.     protected const ERROR_NAMES = [
  25.         self::COMPROMISED_PASSWORD_ERROR => 'COMPROMISED_PASSWORD_ERROR',
  26.     ];
  27.     /**
  28.      * @deprecated since Symfony 6.1, use const ERROR_NAMES instead
  29.      */
  30.     protected static $errorNames self::ERROR_NAMES;
  31.     public $message 'This password has been leaked in a data breach, it must not be used. Please use another password.';
  32.     public $threshold 1;
  33.     public $skipOnError false;
  34.     public function __construct(
  35.         array $options null,
  36.         string $message null,
  37.         int $threshold null,
  38.         bool $skipOnError null,
  39.         array $groups null,
  40.         mixed $payload null
  41.     ) {
  42.         parent::__construct($options$groups$payload);
  43.         $this->message $message ?? $this->message;
  44.         $this->threshold $threshold ?? $this->threshold;
  45.         $this->skipOnError $skipOnError ?? $this->skipOnError;
  46.     }
  47. }