https://g.co/gemini/share/be83c4bc49f6



// src/Validator/Constraints/PasswordRequirements.php
namespace App\Validator\Constraints;

use Symfony\Component\Validator\Constraints\Compound;
use Symfony\Component\Validator\Constraints as Assert;

#[\Attribute]
class PasswordRequirements extends Compound
{
    protected function getConstraints(array $options): array
    {
        return [
            new Assert\NotBlank(),
            new Assert\Type('string'),
            new Assert\Length(['min' => 12]),
            new Assert\NotCompromisedPassword(),
            new Assert\PasswordStrength(['minScore' => 4]),
        ];
    }
}



// src/Entity/User.php
namespace App\Entity\User;

use App\Validator\Constraints as Assert;

class User
{
    #[Assert\PasswordRequirements]
    public string $plainPassword;
}

Powered by Froala Editor