/**
  * Adds an error about the specified attribute to the model object.
  * This is a helper method that performs message selection and internationalization.
  * @param \Leaps\Base\Model $model the data model being validated
  * @param string $attribute the attribute being validated
  * @param string $message the error message
  * @param array $params values for the placeholders in the error message
  */
 public function addError($model, $attribute, $message, $params = [])
 {
     $value = $model->{$attribute};
     $params['attribute'] = $model->getAttributeLabel($attribute);
     $params['value'] = is_array($value) ? 'array()' : $value;
     $model->addError($attribute, Leaps::$app->getI18n()->format($message, $params, Leaps::$app->language));
 }
 /**
  * Returns the client side validation options.
  * @param \Leaps\Base\Model $model the model being validated
  * @param string $attribute the attribute name being validated
  * @return array the client side validation options
  */
 protected function getClientOptions($model, $attribute)
 {
     $label = $model->getAttributeLabel($attribute);
     $options = [];
     if ($this->message !== null) {
         $options['message'] = Leaps::$app->getI18n()->format($this->message, ['attribute' => $label], Leaps::$app->language);
     }
     $options['skipOnEmpty'] = $this->skipOnEmpty;
     if (!$this->skipOnEmpty) {
         $options['uploadRequired'] = Leaps::$app->getI18n()->format($this->uploadRequired, ['attribute' => $label], Leaps::$app->language);
     }
     if ($this->mimeTypes !== null) {
         $options['mimeTypes'] = $this->mimeTypes;
         $options['wrongMimeType'] = Leaps::$app->getI18n()->format($this->wrongMimeType, ['attribute' => $label, 'mimeTypes' => implode(', ', $this->mimeTypes)], Leaps::$app->language);
     }
     if ($this->extensions !== null) {
         $options['extensions'] = $this->extensions;
         $options['wrongExtension'] = Leaps::$app->getI18n()->format($this->wrongExtension, ['attribute' => $label, 'extensions' => implode(', ', $this->extensions)], Leaps::$app->language);
     }
     if ($this->minSize !== null) {
         $options['minSize'] = $this->minSize;
         $options['tooSmall'] = Leaps::$app->getI18n()->format($this->tooSmall, ['attribute' => $label, 'limit' => $this->minSize], Leaps::$app->language);
     }
     if ($this->maxSize !== null) {
         $options['maxSize'] = $this->maxSize;
         $options['tooBig'] = Leaps::$app->getI18n()->format($this->tooBig, ['attribute' => $label, 'limit' => $this->maxSize], Leaps::$app->language);
     }
     if ($this->maxFiles !== null) {
         $options['maxFiles'] = $this->maxFiles;
         $options['tooMany'] = Leaps::$app->getI18n()->format($this->tooMany, ['attribute' => $label, 'limit' => $this->maxFiles], Leaps::$app->language);
     }
     return $options;
 }