/**
  * Validates a single entity by getting the correct validator object from
  * the table and traverses associations passed in $options to validate them
  * as well.
  *
  * @param \Cake\Datasource\EntityInterface $entity The entity to be validated
  * @param array|\ArrayObject $options options for validation, including an optional key of
  *   associations to also be validated. This argument should use the same format as the $options
  *   argument to \Cake\ORM\Table::save().
  * @return bool true if all validations passed, false otherwise
  */
 public function one(EntityInterface $entity, $options = [])
 {
     $valid = true;
     $types = [Association::ONE_TO_ONE, Association::MANY_TO_ONE];
     $propertyMap = $this->_buildPropertyMap($options);
     $options = new ArrayObject($options);
     foreach ($propertyMap as $key => $assoc) {
         $value = $entity->get($key);
         $association = $assoc['association'];
         if (!$value) {
             continue;
         }
         $isOne = in_array($association->type(), $types);
         if ($isOne && !$value instanceof EntityInterface) {
             $valid = false;
             continue;
         }
         $validator = new self($association->target());
         if ($isOne) {
             $valid = $validator->one($value, $assoc['options']) && $valid;
         } else {
             $valid = $validator->many($value, $assoc['options']) && $valid;
         }
     }
     if (!isset($options['validate'])) {
         $options['validate'] = true;
     }
     if (!$entity instanceof ValidatableInterface) {
         return $valid;
     }
     return $this->_processValidation($entity, $options) && $valid;
 }