protected function validate($for) { parent::validate($for); if ($for == 'insert' && self::get($this->language)) { $this->language_error = t('%n is used'); throw new ValidationException($this); } }
protected function validate($for) { parent::validate($for); if (self::get($this->userID, $this->groupID)) { throw new Exception(t('User is already member of group')); } }
protected function validate($for) { parent::validate($for); if ($for == 'insert') { if (self::get($this->name)) { $this->name_error = t('Name already exists'); throw new ValidationException($this); } } else if ($for == 'update') { if ($this->name_changed && self::get($this->name)) { $this->name_error = t('Name already exists'); throw new ValidationException($this); } } }
protected function validate($for) { parent::validate($for); if ($for == 'insert') { $error = false; if ($this->usernameExists($this->username)) { $this->username_error = t('%n is already taken'); $error = true; } if ($this->emailExists($this->email)) { $this->email_error = t('%n is already taken'); $error = true; } if ($this->password != $this->passwordConfirmation) { $this->passwordConfirmation_error = t('Passwords are not equal'); $error = true; } if ($error) { throw new ValidationException($this); } } else if ($for == 'update') { $error = false; if ($this->username_changed && $this->usernameExists($this->username)) { $this->username_error = t('%n is already taken'); $error = true; } if ($this->email_changed && $this->emailExists($this->email)) { $this->email_error = t('%n is already taken'); $error = true; } if ($this->password != null && !$this->forceNewPassword) { $this->validate('updatePassword'); } else if ($this->password != null) { $this->validate('forceNewPassword'); } if ($error) { throw new ValidationException($this); } } else if ($for == 'updatePassword' || $for == 'forceNewPassword') { if ($for == 'updatePassword') { if (!$this->checkPassword($this->oldPassword)) { $this->oldPassword_error = t('Password is wrong'); throw new ValidationException($this); } } if ($this->password != $this->passwordConfirmation) { $this->passwordConfirmation_error = t('Passwords do not match'); throw new ValidationException($this); } } }
protected function validate($for) { parent::validate($for); if ($for == 'insert' && $this->parentID != '') { if (self::translatedInWithParams($this->parentID, $this->datePosted_db, $this->language)) { $this->text_error = t('This blog is already translated in this language'); throw new ValidationException($this); } } }
public function doSomethingSpecialWhichTriggersConditionalValidation() { parent::validate('special'); }
protected function validate($for) { parent::validate($for); if ($for == 'insert') { if ($this->originalLanguage) { $original = Page::get($this->originalID, $this->originalLanguage); if ($original->hasTranslation($this->language)) { $this->title_error = t('This page is already translated'); throw new ValidationException($this); } } } }