/** * Validate a user object. * * Invokes User::validate(), * and additionally tests that the User's email address and username (if set) are unique across all users.'. * * @param User $user * @return array An array of error messages, or an empty array if the User is valid. */ public function validate(AUser $user) { $errors = $user->validate(); // If username is required, ensure it is set. if ($this->isUsernameRequired && !$user->getRealUsername()) { $errors['username'] = '******'; } return $errors; }