src/Form/Validators/Length.php
public function isValid($valeur)
  {
    parent::resetErrors();

    $min = $this->getArgValue('min');
    $max = $this->getArgValue('max');

    if ($min == $max) {
      if (strlen($valeur) != $min) {
        parent::addError($this->prepareError('valisatorerror_length_exact'));
        return false;
      }
    } else if ($min == -1) {
      if (strlen($valeur) > $max) {
        parent::addError($this->prepareError('valisatorerror_length_max'));
        return false;
      }
    } else if ($max == -1) {
      if (strlen($valeur) < $min) {
        parent::addError($this->prepareError('valisatorerror_length_min'));
        return false;
      }
    } else {
      if (strlen($valeur) < $min || strlen($valeur) > $max) {
        parent::addError($this->prepareError('valisatorerror_length_range'));
        return false;
      }
    }

    return true;
  }
public function isValid($valeur)
  {
    parent::resetErrors();

    $min = $this->getArgValue('min');
    $max = $this->getArgValue('max');

    if ($min == $max) {
      if (strlen($valeur) != $min) {
        parent::addError($this->prepareError('valisatorerror_length_exact'));
        return false;
      }
    } else if ($min == -1) {
      if (strlen($valeur) > $max) {
        parent::addError($this->prepareError('valisatorerror_length_max'));
        return false;
      }
    } else if ($max == -1) {
      if (strlen($valeur) < $min) {
        parent::addError($this->prepareError('valisatorerror_length_min'));
        return false;
      }
    } else {
      if (strlen($valeur) < $min || strlen($valeur) > $max) {
        parent::addError($this->prepareError('valisatorerror_length_range'));
        return false;
      }
    }

    return true;
  }
Teste la validité

@param mixed $valeur Valeur à tester
@return boolean