FOS\UserBundle\Model\UserManagerInterface::validateUnique PHP Метод

validateUnique() публичный Метод

Checks the uniqueness of the given fields, returns true if its unique
public validateUnique ( FOS\UserBundle\Model\UserInterface $value, Constraint $constraint ) : boolean
$value FOS\UserBundle\Model\UserInterface
$constraint Symfony\Component\Validator\Constraint
Результат boolean
    function validateUnique($value, Constraint $constraint);

Usage Example

Пример #1
0
 /**
  * Checks if the passed value is valid.
  *
  * @param mixed      $value      The value that should be validated
  * @param Constraint $constraint The constrain for the validation
  *
  * @return Boolean Whether or not the value is valid
  *
  * @throws UnexpectedTypeException if $value is not instance of \FOS\UserBundle\Model\UserInterface
  */
 public function isValid($value, Constraint $constraint)
 {
     if (!$value instanceof UserInterface) {
         throw new UnexpectedTypeException($value, 'FOS\\UserBundle\\Model\\UserInterface');
     }
     if (!$this->userManager->validateUnique($value, $constraint)) {
         $this->setMessage($constraint->message, array('%property%' => $constraint->property));
         return false;
     }
     return true;
 }