3 final class PhortuneAccountEmailAddressTransaction
4 extends PhortuneAccountEmailTransactionType
{
6 const TRANSACTIONTYPE
= 'address';
8 public function generateOldValue($object) {
9 return $object->getAddress();
12 public function applyInternalEffects($object, $value) {
13 $object->setAddress($value);
16 public function validateTransactions($object, array $xactions) {
19 if ($this->isEmptyTextTransaction($object->getAddress(), $xactions)) {
20 $errors[] = $this->newRequiredError(
21 pht('You must provide an email address.'));
24 $max_length = $object->getColumnMaximumByteLength('address');
25 foreach ($xactions as $xaction) {
26 $old_value = $xaction->getOldValue();
27 $new_value = $xaction->getNewValue();
29 $new_length = strlen($new_value);
30 if ($new_length > $max_length) {
31 $errors[] = $this->newInvalidError(
33 'The address can be no longer than %s characters.',
34 new PhutilNumber($max_length)),
39 if (!PhabricatorUserEmail
::isValidAddress($new_value)) {
40 $errors[] = $this->newInvalidError(
41 PhabricatorUserEmail
::describeValidAddresses(),
46 if ($new_value !== $old_value) {
47 if (!$this->isNewObject()) {
48 $errors[] = $this->newInvalidError(
50 'Account email addresses can not be edited once they are '.
51 'created. To change the billing address for an account, '.
52 'disable the old address and then add a new address.'),