You are here

class LogintobogganPasswordLengthValidator in LoginToboggan 8

Validates length of password.

Hierarchy

Expanded class hierarchy of LogintobogganPasswordLengthValidator

File

src/Plugin/Validation/Constraint/LogintobogganPasswordLengthValidator.php, line 11

Namespace

Drupal\logintoboggan\Plugin\Validation\Constraint
View source
class LogintobogganPasswordLengthValidator extends ConstraintValidator {

  /**
   * Check lenth of password.
   *
   * {@inheritdoc}
   */
  public function validate($value, Constraint $constraint) {
    $gotpass = $value
      ->getValue();
    if (!empty($gotpass)) {
      $pass = $value
        ->get(0)->value;
      $min_pass_length = \Drupal::config('logintoboggan.settings')
        ->get('minimum_password_length');
      if (strlen($pass) > 0 && strlen($pass) < $min_pass_length) {
        $this->context
          ->addViolation($constraint->message, [
          '%length' => $min_pass_length,
        ]);
      }
    }
  }

}

Members