public static function loadValidatorMetadata(ClassMetadata $metadata)
    {
        $metadata->addPropertyConstraint('username', new NotBlank(['message' => 'silex_user.username.blank']));
        $metadata->addPropertyConstraint('username', new Length([
            'min' => 2,
            'max' => 180,
            'minMessage' => 'silex_user.username.short',
            'maxMessage' => 'silex_user.username.long'
        ]));
        $metadata->addPropertyConstraint('username', new Regex([
            'pattern' => '/^[a-z0-9._-]+$/i',
            'message' => 'silex_user.username.invalid'
        ]));

        $metadata->addPropertyConstraint('email', new NotBlank(['message' => 'silex_user.email.blank']));
        $metadata->addPropertyConstraint('email', new Length([
            'max' => 180,
            'maxMessage' => 'silex_user.email.long'
        ]));
        $metadata->addPropertyConstraint('email', new Email(['message' => 'silex_user.email.invalid']));

        $metadata->addPropertyConstraint('plainPassword', new NotBlank(['message' => 'silex_user.password.blank']));
        $metadata->addPropertyConstraint('plainPassword', new Length([
            'min' => 2,
            'max' => 255,
            'minMessage' => 'silex_user.password.short',
            'maxMessage' => 'silex_user.password.long'
        ]));
    }