Neos\Flow\Validation\Validator\GenericObjectValidator::validate PHP Метод

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

Checks if the given value is valid according to the validator, and returns the Error Messages object which occurred.
public validate ( mixed $value ) : Neos\Error\Messages\Result
$value mixed The value that should be validated
Результат Neos\Error\Messages\Result
    public function validate($value)
    {
        $this->result = new ErrorResult();
        if ($this->acceptsEmptyValues === false || $this->isEmpty($value) === false) {
            if (!is_object($value)) {
                $this->addError('Object expected, %1$s given.', 1241099149, [gettype($value)]);
            } elseif ($this->isValidatedAlready($value) === false) {
                $this->isValid($value);
            }
        }
        return $this->result;
    }

Usage Example

 /**
  * Checks if the given value is valid according to the validator, and returns
  * the Error Messages object which occurred. Will skip validation if value is
  * an uninitialized lazy loading proxy.
  *
  * @param mixed $value The value that should be validated
  * @return \Neos\Error\Messages\Result
  * @api
  */
 public function validate($value)
 {
     $this->result = new Result();
     /**
      * The idea is that Aggregates form a consistency boundary, and an Aggregate only needs to be
      * validated if it changed state. Also since all entity relations are lazy loaded by default,
      * and the relation will only be initialized when it gets accessed (e.g. during property mapping),
      * we can just skip validation of an uninitialized aggregate.
      * This greatly improves validation performance for domain models with lots of small aggregate
      * relations. Therefore proper Aggregate Design becomes a performance optimization.
      */
     if ($value instanceof \Doctrine\ORM\Proxy\Proxy && !$value->__isInitialized()) {
         return $this->result;
     }
     return parent::validate($value);
 }
All Usage Examples Of Neos\Flow\Validation\Validator\GenericObjectValidator::validate