code: public function init()
      {
          parent::init();
          if (is_array($this->length)) {
              if (isset($this->length[0])) {
                  $this->min = $this->length[0];
              }
              if (isset($this->length[1])) {
                  $this->max = $this->length[1];
              }
              $this->length = null;
          }
          if ($this->encoding === null) {
              $this->encoding = Yii::$app ? Yii::$app->charset : 'UTF-8';
          }
          if ($this->message === null) {
              $this->message = Yii::t('yii', '{attribute} must be a string.');
          }
          if ($this->min !== null && $this->tooShort === null) {
              $this->tooShort = Yii::t('yii', '{attribute} should contain at least {min, number} {min, plural, one{character} other{characters}}.');
          }
          if ($this->max !== null && $this->tooLong === null) {
              $this->tooLong = Yii::t('yii', '{attribute} should contain at most {max, number} {max, plural, one{character} other{characters}}.');
          }
          if ($this->length !== null && $this->notEqual === null) {
              $this->notEqual = Yii::t('yii', '{attribute} should contain {length, number} {length, plural, one{character} other{characters}}.');
          }
      }
docs: {@inheritdoc}