/**
  * @inheritdoc
  */
 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 = Leaps::$app->charset;
     }
     if ($this->message === null) {
         $this->message = Leaps::t('leaps', '{attribute} must be a string.');
     }
     if ($this->min !== null && $this->tooShort === null) {
         $this->tooShort = Leaps::t('leaps', '{attribute} should contain at least {min, number} {min, plural, one{character} other{characters}}.');
     }
     if ($this->max !== null && $this->tooLong === null) {
         $this->tooLong = Leaps::t('leaps', '{attribute} should contain at most {max, number} {max, plural, one{character} other{characters}}.');
     }
     if ($this->length !== null && $this->notEqual === null) {
         $this->notEqual = Leaps::t('leaps', '{attribute} should contain {length, number} {length, plural, one{character} other{characters}}.');
     }
 }
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if ($this->message === null) {
         $this->message = $this->requiredValue === null ? Leaps::t('leaps', '{attribute} cannot be blank.') : Leaps::t('leaps', '{attribute} must be "{requiredValue}".');
     }
 }
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if ($this->message === null) {
         $this->message = Leaps::t('leaps', '{attribute} "{value}" has already been taken.');
     }
 }
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if ($this->filter === null) {
         throw new InvalidConfigException('The "filter" property must be set.');
     }
 }
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if ($this->message === null) {
         $this->message = Leaps::t('leaps', 'The verification code is incorrect.');
     }
 }
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if ($this->message === null) {
         $this->message = Leaps::t('leaps', '{attribute} must be either "{true}" or "{false}".');
     }
 }
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if ($this->message === null) {
         switch ($this->operator) {
             case '==':
                 $this->message = Leaps::t('leaps', '{attribute} must be repeated exactly.');
                 break;
             case '===':
                 $this->message = Leaps::t('leaps', '{attribute} must be repeated exactly.');
                 break;
             case '!=':
                 $this->message = Leaps::t('leaps', '{attribute} must not be equal to "{compareValue}".');
                 break;
             case '!==':
                 $this->message = Leaps::t('leaps', '{attribute} must not be equal to "{compareValue}".');
                 break;
             case '>':
                 $this->message = Leaps::t('leaps', '{attribute} must be greater than "{compareValue}".');
                 break;
             case '>=':
                 $this->message = Leaps::t('leaps', '{attribute} must be greater than or equal to "{compareValue}".');
                 break;
             case '<':
                 $this->message = Leaps::t('leaps', '{attribute} must be less than "{compareValue}".');
                 break;
             case '<=':
                 $this->message = Leaps::t('leaps', '{attribute} must be less than or equal to "{compareValue}".');
                 break;
             default:
                 throw new InvalidConfigException("Unknown operator: {$this->operator}");
         }
     }
 }
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if ($this->message === null) {
         $this->message = Leaps::t('leaps', '{attribute} is invalid.');
     }
 }
Example #9
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if ($this->enableIDN && !function_exists('idn_to_ascii')) {
         throw new InvalidConfigException('In order to use IDN validation intl extension must be installed and enabled.');
     }
     if ($this->message === null) {
         $this->message = Leaps::t('leaps', '{attribute} is not a valid URL.');
     }
 }
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if ($this->pattern === null) {
         throw new InvalidConfigException('The "pattern" property must be set.');
     }
     if ($this->message === null) {
         $this->message = Leaps::t('leaps', '{attribute} is invalid.');
     }
 }
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if ($this->message === null) {
         $this->message = $this->integerOnly ? Leaps::t('leaps', '{attribute} must be an integer.') : Leaps::t('leaps', '{attribute} must be a number.');
     }
     if ($this->min !== null && $this->tooSmall === null) {
         $this->tooSmall = Leaps::t('leaps', '{attribute} must be no less than {min}.');
     }
     if ($this->max !== null && $this->tooBig === null) {
         $this->tooBig = Leaps::t('leaps', '{attribute} must be no greater than {max}.');
     }
 }
Example #12
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if ($this->message === null) {
         $this->message = Leaps::t('leaps', 'The format of {attribute} is invalid.');
     }
     if ($this->format === null) {
         $this->format = Leaps::$app->formatter->dateFormat;
     }
     if ($this->locale === null) {
         $this->locale = Leaps::$app->language;
     }
     if ($this->timeZone === null) {
         $this->timeZone = Leaps::$app->timeZone;
     }
     if ($this->min !== null && $this->tooSmall === null) {
         $this->tooSmall = Leaps::t('leaps', '{attribute} must be no less than {min}.');
     }
     if ($this->max !== null && $this->tooBig === null) {
         $this->tooBig = Leaps::t('leaps', '{attribute} must be no greater than {max}.');
     }
     if ($this->maxString === null) {
         $this->maxString = (string) $this->max;
     }
     if ($this->minString === null) {
         $this->minString = (string) $this->min;
     }
     if ($this->max !== null && is_string($this->max)) {
         $timestamp = $this->parseDateValue($this->max);
         if ($timestamp === false) {
             throw new InvalidConfigException("Invalid max date value: {$this->max}");
         }
         $this->max = $timestamp;
     }
     if ($this->min !== null && is_string($this->min)) {
         $timestamp = $this->parseDateValue($this->min);
         if ($timestamp === false) {
             throw new InvalidConfigException("Invalid min date value: {$this->min}");
         }
         $this->min = $timestamp;
     }
 }
Example #13
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if ($this->message === null) {
         $this->message = Leaps::t('leaps', 'File upload failed.');
     }
     if ($this->uploadRequired === null) {
         $this->uploadRequired = Leaps::t('leaps', 'Please upload a file.');
     }
     if ($this->tooMany === null) {
         $this->tooMany = Leaps::t('leaps', 'You can upload at most {limit, number} {limit, plural, one{file} other{files}}.');
     }
     if ($this->wrongExtension === null) {
         $this->wrongExtension = Leaps::t('leaps', 'Only files with these extensions are allowed: {extensions}.');
     }
     if ($this->tooBig === null) {
         $this->tooBig = Leaps::t('leaps', 'The file "{file}" is too big. Its size cannot exceed {limit, number} {limit, plural, one{byte} other{bytes}}.');
     }
     if ($this->tooSmall === null) {
         $this->tooSmall = Leaps::t('leaps', 'The file "{file}" is too small. Its size cannot be smaller than {limit, number} {limit, plural, one{byte} other{bytes}}.');
     }
     if (!is_array($this->extensions)) {
         $this->extensions = preg_split('/[\\s,]+/', strtolower($this->extensions), -1, PREG_SPLIT_NO_EMPTY);
     } else {
         $this->extensions = array_map('strtolower', $this->extensions);
     }
     if ($this->wrongMimeType === null) {
         $this->wrongMimeType = Leaps::t('leaps', 'Only files with these MIME types are allowed: {mimeTypes}.');
     }
     if (!is_array($this->mimeTypes)) {
         $this->mimeTypes = preg_split('/[\\s,]+/', strtolower($this->mimeTypes), -1, PREG_SPLIT_NO_EMPTY);
     } else {
         $this->mimeTypes = array_map('strtolower', $this->mimeTypes);
     }
 }