Пример #1
0
 /**
  * Returns the validation rules of the model.
  * @return array validation rules
  */
 public function validate()
 {
     if (empty($this->name)) {
         $this->setValidationError('name', sprintf(\GO::t('attributeRequired'), 'name'));
     }
     if (empty($this->email)) {
         $this->setValidationError('email', sprintf(\GO::t('attributeRequired'), 'email'));
     }
     if (empty($this->message)) {
         $this->setValidationError('message', sprintf(\GO::t('attributeRequired'), 'message'));
     }
     if (!\GO\Base\Util\Validate::email($this->email)) {
         $this->setValidationError('email', \GO::t('invalidEmailError'));
     }
     return parent::validate();
 }
Пример #2
0
 public function validate()
 {
     if (!empty($this->vat_no) && \GO\Base\Util\Validate::isEuCountry($this->post_country)) {
         if (substr($this->vat_no, 0, 2) != $this->post_country) {
             $this->vat_no = $this->post_country . ' ' . $this->vat_no;
         }
         if ($this->checkVatNumber && ($this->isModified('vat_no') || $this->isModified('post_country')) && !\GO\Base\Util\Validate::checkVat($this->post_country, $this->vat_no)) {
             $this->setValidationError('vat_no', 'European VAT (Country:' . $this->post_country . ', No.:' . $this->vat_no . ') number is invalid according to VIES. Please click <a target="_blank" href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">here</a> to check it on their website.');
         }
     }
     return parent::validate();
 }
Пример #3
0
 public function validate()
 {
     if ($this->max_rows_list > 250) {
         $this->setValidationError('max_rows_list', GO::t('maxRowslistTooHigh'));
     }
     if ($this->isModified('password') && isset($this->passwordConfirm) && $this->passwordConfirm != $this->password) {
         $this->setValidationError('passwordConfirm', GO::t('passwordMatchError'));
     }
     if ($this->isModified('disk_quota') && !GO::$ignoreAclPermissions && GO::user()->getModulePermissionLevel('users') < Acl::MANAGE_PERMISSION) {
         $this->setValidationError('disk_quota', 'Only managers of the "users"  module may modify disk quota');
     }
     if (GO::config()->password_validate && $this->isModified('password')) {
         if (!\GO\Base\Util\Validate::strongPassword($this->password)) {
             $this->setValidationError('password', \GO\Base\Util\Validate::getPasswordErrorString($this->password));
         }
     }
     if ($this->isNew && $this->_maxUsersReached()) {
         $this->setValidationError('form', GO::t('max_users_reached', 'users'));
     }
     if (!GO::config()->allow_duplicate_email) {
         $existing = $this->findSingleByAttribute('email', $this->email);
         if ($this->isNew && $existing || $existing && $existing->id != $this->id) {
             $this->setValidationError('email', GO::t('error_email_exists', 'users'));
         }
     }
     $existing = $this->findSingleByAttribute('username', $this->username);
     if ($this->isNew && $existing || $existing && $existing->id != $this->id) {
         $this->setValidationError('username', GO::t('error_username_exists', 'users'));
     }
     if (empty($this->password) && $this->isNew) {
         $this->password = \GO\Base\Util\String::randomPassword();
         $this->generatedRandomPassword = true;
     }
     return parent::validate();
 }