/**
  * Check if the payable is valid against the address validation rules.
  *
  * @todo Add validation of the address against valid countries.
  *
  * {@inheritDoc}
  */
 public function isValid(PayableInterface $payable)
 {
     $valid = true;
     $address = $payable->getPayableAddress($this->_type);
     // Check the address exists
     if (!$address) {
         $this->_errors[] = sprintf("%s address is required", ucfirst($this->_type));
         return false;
     }
     // Check the address parts
     foreach ($this->_parts as $key => $part) {
         if ($key === "lines") {
             for ($line = 1; $line <= $part; $line++) {
                 if (!property_exists($address, "lines") or !is_array($address->lines) or !isset($address->lines[$line])) {
                     $valid = false;
                     $this->_errors[] = sprintf("%s address line %d is required", ucfirst($this->_type), $line);
                 }
             }
         } else {
             if (!property_exists($address, $part) or !$address->{$part}) {
                 $valid = false;
                 $this->_errors[] = sprintf("%s address %s is required", ucfirst($this->_type), $part);
             }
         }
     }
     // Check the address state is set where required by the country and
     // matches the states within that country.
     $states = $this->_states->all();
     if (isset($states[$address->countryID])) {
         if (empty($address->stateID)) {
             $valid = false;
             $this->_errors[] = sprintf("%s address state is required", ucfirst($this->_type));
         } elseif (!isset($states[$address->countryID][$address->stateID])) {
             $valid = false;
             $this->_errors[] = sprintf("%s address state '%s' is not in the country '%s'", ucfirst($this->_type), $address->stateID, $address->countryID);
         }
     }
     return $valid;
 }