/** * Model validation ensures that any data that is present in the model is * formatted correctly. No business logic validation is performed at this * level. * * @throws InvalidRequestException if validation fails. */ public function validate() { if (strlen($this['PaymentAccountID']) && !preg_match('/^.{1,50}$/', $this['PaymentAccountID'])) { throw new InvalidRequestException('PaymentAccountID should have 50 or fewer characters'); } if (isset($this['PaymentAccountType'])) { try { PaymentAccountType::memberByValue($this['PaymentAccountType']); } catch (\Exception $e) { throw new InvalidRequestException('Invalid value for PaymentAccountType'); } } if (strlen($this['PaymentAccountReferenceNumber'])) { if (!preg_match('/^.{1,50}$/', $this['PaymentAccountReferenceNumber'])) { throw new InvalidRequestException('PaymentAccountReferenceNumber should have 50 or fewer characters'); } } if (strlen($this['PaymentBrand']) && !preg_match('/^.{1,50}$/', $this['PaymentBrand'])) { throw new InvalidRequestException('PaymentBrand should have 50 or fewer characters'); } if (strlen($this['ExpirationMonthBegin'])) { if (!preg_match('/^\\d{2}$/', $this['ExpirationMonthBegin']) || $this['ExpirationMonthBegin'] > 12) { throw new InvalidRequestException('ExpirationMonthBegin should be a two-digit month'); } } if (strlen($this['ExpirationMonthEnd'])) { if (!preg_match('/^\\d{2}$/', $this['ExpirationMonthEnd']) || $this['ExpirationMonthEnd'] > 12) { throw new InvalidRequestException('ExpirationMonthEnd should be a two-digit month'); } } if (strlen($this['ExpirationYearBegin']) && !preg_match('/^\\d{2}$/', $this['ExpirationYearBegin'])) { throw new InvalidRequestException('ExpirationYearBegin should be a two-digit year'); } if (strlen($this['ExpirationYearEnd']) && !preg_match('/^\\d{2}$/', $this['ExpirationYearEnd'])) { throw new InvalidRequestException('ExpirationYearEnd should be a two-digit year'); } if (strlen($this['ExpirationYearBegin']) && strlen($this['ExpirationYearEnd'])) { if ($this['ExpirationYearEnd'] < $this['ExpirationYearBegin']) { throw new InvalidRequestException('ExpirationYearBegin must be before ExpirationYearEnd'); } if (strlen($this['ExpirationMonthBegin']) && strlen($this['ExpirationMonthEnd'])) { if ($this['ExpirationYearBegin'] == $this['ExpirationYearEnd']) { if ($this['ExpirationMonthEnd'] < $this['ExpirationMonthBegin']) { throw new InvalidRequestException('ExpirationMonthBegin must be before ExpirationMonthEnd'); } } } } }
/** * Model validation ensures that any data that is present in the model is * formatted correctly. No business logic validation is performed at this * level. * * @throws InvalidRequestException if validation fails. */ public function validate() { if (strlen($this['PaymentAccountID']) && !preg_match('/^.{1,50}$/', $this['PaymentAccountID'])) { throw new InvalidRequestException('PaymentAccountID should have 50 or fewer characters'); } if (isset($this['PaymentAccountType'])) { try { PaymentAccountType::memberByValue($this['PaymentAccountType']); } catch (\Exception $e) { throw new InvalidRequestException('Invalid value for PaymentAccountType'); } } if (strlen($this['PaymentAccountReferenceNumber'])) { if (!preg_match('/^.{1,50}$/', $this['PaymentAccountReferenceNumber'])) { throw new InvalidRequestException('PaymentAccountReferenceNumber should have 50 or fewer characters'); } } }
public function setPaymentAccountType($value) { $value = PaymentAccountType::memberByValue($value)->value(); return $this->setParameter('PaymentAccountType', $value); }