Validate constraints.
@param $value
@return true|array True on success, error will give array that contains error messages.
963206
public function valid ($value)
    {
        $valid = true;
        $error = array();

        if ($this->minLength !== null && ! (strlen($value) >= $this->minLength)) {
            $valid = false;
            $error[] = 'minimum length';
        }

        if ($this->maxLength !== null && ! (strlen($value) <= $this->maxLength)) {
            $valid = false;
            $error[] = 'maximum length';
        }

        // var_dump(array('cur' => $value, 'min' => $this->minValue));
        if ($this->minValue !== null && (! is_numeric($value) || ! ($value >= $this->minValue))) {
            $valid = false;
            $error[] = 'minimum value';
        }

        if ($this->maxValue !== null && (! is_numeric($value) || ! ($value <= $this->maxValue))) {
            $valid = false;
            $error[] = 'maximum value';
        }

        if ($this->startsWith !== null && ! (strpos($value, $this->startsWith) === 0)) {
            $valid = false;
            $error[] = 'starts with';
        }

        if ($this->endsWith !== null && ! (strpos($value, $this->endsWith) === strlen($value)-strlen($this->endsWith))) {
            $valid = false;
            $error[] = 'ends with';
        }

        if ($this->regex !== null && ! preg_match($this->regex, $value)) {
            $valid = false;
            $error[] = 'valid custom field';
        }

        if ($this->enum !== null && is_array($this->enum)) {
            if (! in_array($value, $this->enum)) {
                $valid = false;
                $error[] = 'is value of list';
            }
        }

        if ($this->valid !== null) {
            switch ($this->valid) {
                case 'email':
                    if (! filter_var($value, FILTER_VALIDATE_EMAIL))
                        $valid = false;
                    break;
                case 'url':
                    if (! filter_var($value, FILTER_VALIDATE_URL))
                        $valid = false;
                    break;
                default:
                    $valid = false;
            }
        }
        if (! $valid) {
            $error[] = 'valid \'' . $this->valid . '\'';
        }

        return $valid === true ? true : $error;
    }
876437
private function validateConstraints(array $constraints): bool
    {
        foreach ($constraints as $constraint) {
            if (!$constraint instanceof Closure && !$constraint instanceof Constraint) {
                return false;
            }
        }

        return true;
    }
207205
public function isValid($value) {
		$valid = true;
		if(!empty($this->validation)) {
			if(!empty($this->label))
				$element = $this->label;
			elseif(!empty($this->_attributes["placeholder"]))
				$element = $this->_attributes["placeholder"];
			else
				$element = $this->_attributes["name"];

			if(substr($element, -1) == ":")
				$element = substr($element, 0, -1);

			foreach($this->validation as $validation) {
				if(!$validation->isValid($value)) {
					/*In the error message, %element% will be replaced by the element's label (or 
					name if label is not provided).*/
					$this->_errors[] = str_replace("%element%", $element, $validation->getMessage());
					$valid = false;
				}	
			}
		}
		return $valid;
	}
576289
protected function isValid(&$value): ConstraintInterface
    {
        if ($this->constraintsSet instanceof ConstraintsSetInterface) {
            $this->constraintsSet->isValid($value);
        }

        return $this;
    }
1298290
public function isValid($value = null, array $options = []): bool
    {
        if (\count($options) > 0) {
            $this->setOptions($options);
        }
        $this->setValue($value);
        $this->errors = [];

        $validType = $this->validateType();
        $validGT = $this->validateGreaterThan();
        $validLT = $this->validateLowerThan();

        return $validType && $validGT && $validLT;
    }
473955
public function isValid($value) {
		if ($this->instance === null) {
			throw new ValidationFailure('Reference class or interface wasn\'t been suplied');
		}
		
		if ($value instanceof $this->instance) {
			return true;
		}
		
		$this->addMessage('Value must be an instance of the "' . $this->instance . '"');
		
		return false;
	}
1328159
public function isValid($value, Constraint $constraint)
    {
        $document = $this->parseDocument($value);
        $fields = $this->parseFields($constraint->fields);
        $caseInsensitive = $this->parseCaseInsensitive($constraint->caseInsensitive);

        $query = $this->createQuery($document, $fields, $caseInsensitive);
        $numberResults = $query->count();

        if (0 === $numberResults) {
            return true;
        }

        if (1 === $numberResults) {
            $result = $query->one();
            if ($result === $document) {
                return true;
            }
        }

        if ($this->context) {
            $this->addFieldViolation($fields[0], $constraint->message);
        }

        return false;
    }
691181
public function validateMessage($value)
  {
    if (is_string($value)) {
      $result = true;
    } elseif (is_object($value) && method_exists($value, "__toString")) {
      $result = true;
    } else {
      $result = false;
    }
    
    return $result;
  }
117248
public function validate($value)
    {
        $value = trim($value);
        return (is_string($value) && ($value === filter_var($value, FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES)));
    }
482889
public function validate($value)
    {
        if ($this->notBeEmpty($value)) {
            $value = json_decode($value);
            if ($value !== null) {
                return true;
            } else {
                return false;
            }
        } else {
            return false;
        }
    }
935893
public function isValid($value)
    {
        $valid = true;

        if (!empty($this->validation)) {
            if (!empty($this->label)) {
                $element = $this->label;
            } elseif (!empty($this->attributes["placeholder"])) {
                $element = $this->attributes["placeholder"];
            } else {
                $element = $this->attributes["name"];
            }

            if (substr($element, -1) == ":") {
                $element = substr($element, 0, -1);
            }

            foreach ($this->validation as $validation) {
                if (!$validation->isValid($value)) {
                    /*In the error message, %element% will be replaced by the element's label (or
                                        name if label is not provided).*/
                    $this->errors[] = str_replace("%element%", $element, $validation->getMessage());
                    $valid          = false;
                }
            }
        }

        return $valid;
    }
132956
public function validateValue( $value ) : bool
   {

      if ( false === $this->hasValidator() )
      {
         return true;
      }

      return (bool) ( $this->_validator )( $value );

   }
370220
public function validate($value)
    {
        $result = !$this->isRequired;
        if ($this->isRequired()) {
            $result = !empty($value);
        }
        if (is_callable($this->validator)) {
            $result = call_user_func($this->validator, $value);
        }

        return $result;
    }
461865
public function validate($value, Constraint $constraint)
    {
        $this->values = $constraint->values;
        $startMethod = 'get' . $constraint->startField;
        $endMethod = 'get' . $constraint->endField;
        for ($i = 0; $i < count($value); $i++) {
            $entity = $value[$i];

            $startIdx = $this->getIndex($entity->$startMethod());
            $endIdx = $this->getIndex($entity->$endMethod());

            if ($startIdx >= $endIdx) {
                $this->context->addViolation('error.start_end_time_incoherent');

                return false;
            }
            for ($j = $i + 1; $j < count($value); $j++) {
                $entityToCheck = $value[$j];
                $startIdxToCheck = $this->getIndex($entityToCheck->$startMethod());
                $endIdxToCheck = $this->getIndex($entityToCheck->$endMethod());
                if ($this->idxIsInOtherEntity($startIdx, $startIdxToCheck, $endIdxToCheck) ||
                    $this->idxIsInOtherEntity($endIdx, $startIdxToCheck, $endIdxToCheck) ||
                    $this->entityIsIncludedInAnother($startIdx, $endIdx, $startIdxToCheck, $endIdxToCheck) ||
                    $this->entityIsIncludedInAnother($startIdxToCheck, $endIdxToCheck, $startIdx, $endIdx)
                ) {
                    $this->context->addViolation('error.entities_overlapping', array(
                        '%firstElement%' => $i + 1,
                        '%secondElement%' => $j + 1,
                    ));

                    return false;
                }
            }
        }

        return true;
    }
286939
public static function validate($value)
    {
        if (!is_array($value)) {
            return false;
        }
        if (isset($value['from']) && IdentityValidator::validate($value['from']) === false) {
            return false;
        }
        if (isset($value['to']) && IdentityValidator::validate($value['to']) === false) {
            return false;
        }
        if (!isset($value['topics']) || !is_array($value['topics'])) {
            return false;
        }
        foreach ($value['topics'] as $topic) {
            if (IdentityValidator::validate($topic) === false) {
                return false;
            }
        }
        if (!isset($value['payload'])) {
            return false;
        }
        if (HexValidator::validate($value['payload']) === false) {
            return false;
        }
        if (!isset($value['priority'])) {
            return false;
        }
        if (QuantityValidator::validate($value['priority']) === false) {
            return false;
        }
        if (!isset($value['ttl'])) {
            return false;
        }
        if (isset($value['ttl']) && QuantityValidator::validate($value['ttl']) === false) {
            return false;
        }
        return true;
    }
806341
public function validateValueFixedPriceRule($value)
    {
        $field = 'value';
        $label = $this->translation->text('Value');

        if (!is_numeric($value)) {
            $this->setErrorNumeric($field, $label);
            return false;
        }

        if (strlen($value) > 8) {
            $this->setErrorInvalid($field, $label);
            return false;
        }

        return true;
    }
944564
public function validate($value, Constraint $constraint)
    {
        $check = $this->container->get('admin.configuration.configvalue_manager')->getRepository()->findOneBySectionGroupAndValueName(
            $value->getConfigGroup()->getConfigSection()->getName(),
            $value->getConfigGroup()->getName(),
            $value->getName()
        );
        if ( $check && $check->getId() != $value->getId()) {
            $message = $this->container->get('translator')->trans(
                $constraint->message,
                array(
                    '%value%' => $value->getName(),
                    '%group%' => $value->getConfigGroup()->getName(),
                    '%section%' => $value->getConfigGroup()->getConfigSection()->getName()
                ),
                'VinceTAdminConfigurationBundle'
            );
            $this->context->addViolation($message);
        }
    }