Ejemplo n.º 1
0
 /**
  * @param  Record $record
  * @throws \InvalidArgumentException
  * @return bool
  */
 public function validate($record)
 {
     if ($this->isCheckDisabled(self::CODE_RECORD_UNIQUE)) {
         return true;
     }
     if (!$record instanceof Record) {
         throw new \InvalidArgumentException("Expects record instance as #1 argument");
     }
     if ($record->exists() && !$record->isModified()) {
         return true;
     }
     $uniqueIndexesToCheck = $this->getUniqueConstraintsToCheck($record);
     return $this->isRecordIsUnique($record, $uniqueIndexesToCheck);
 }