Checks if the field meets the requirements of the constraints in the
particle's FIELDS constant.

@return void

@throws \InvalidArgumentException thrown when there argument does not meet the constraints.
341333
public function probe(): void
    {
        if(!isset($this->settings["constraints"])) 
            return;
        $constraints = $this->settings["constraints"];
        foreach($constraints as $constraint=>$constraint_val) {
            if(is_null($constraint_val))
                continue;
            switch($constraint) {
                case "format":
                    if(!in_array($constraint_val, [
                         "numeric",
                         "ip",
                         "email",
                         "url",
                         "creditCard",
                         "alpha",
                         "alphaNum"
                         // "date" // there is already the Date field
                    ])) {
                        /*
                        if($constraint_val == "uuid" || $constraint_val == "udid") {
                            try {
                                ID::fromString($this->value);
                            }
                            catch(LibGraph\Exceptions\MalformedIDException $e) {
                                throw new \InvalidArgumentException;
                            }
                        }
                        else {
                            throw new \InvalidArgumentException;
                        }
                        */
                        throw new \InvalidArgumentException;
                    }
                    $v = new Validator(["field"=>$this->value]);
                    $v->rule($constraint_val, "field");
                    if(!$v->validate()) {
                        throw new \InvalidArgumentException;
                    }
                    break;
                //case "dateFormat":
                case "dateBefore":
                case "dateAfter":
                    $v = new Validator(["field"=>$this->value]);
                    $v->rule($constraint, "field", $constraint_val);
                    if(!$v->validate()) {
                        throw new \InvalidArgumentException;
                    }
                    break;
                case "minLength":
                case "maxLength":
                case "greaterThan":
                case "lessThan":
                    Assert::$constraint($this->value, $constraint_val);
                    break;
                               
                case "id":
                    try {
                        ID::fromString($this->value);
                    }
                    catch(LibGraph\Exceptions\MalformedIDException $e) {
                        throw new \InvalidArgumentException;
                    }
                    break;
                
                case "regex":
                    /*
                    if($constraint_val[0]!="/")
                        Assert::$constraint($this->value, "/".addslashes($constraint_val)."/");
                    else*/
                        Assert::$constraint($this->value, $constraint_val);
                    break;
             } 
        }
    }
51612
protected function validate()
    {
        if (!in_array($this->operation, self::$allowedOperations, true)) {
            throw new InvalidArgumentException('Unsupported condition operation');
        }

        if (!is_array($this->value) && $this->isArrayOperation()) {
            throw new InvalidArgumentException('Value is not of type array');
        }

        if (is_array($this->value) && $this->isRangeOperation() && count($this->value) < 2) {
            throw new InvalidArgumentException('Wrong number of values for range');
        }
    }
130744
private function assertValidField(string $field) : void
    {
        if (! isset($this->entityChangeSet[$field])) {
            throw new InvalidArgumentException(sprintf(
                'Field "%s" is not a valid field of the entity "%s" in PreUpdateEventArgs.',
                $field,
                get_class($this->getObject())
            ));
        }
    }
1237197
public function validate()
    {
        foreach ($this->getFields() as $field) {
            if (! isset($this->submittedData[$field->getName()])) {
                continue;
            }
            
            // is it mandatory and empty?
            if ($field->isMandatory() && strlen($this->submittedData[$field->getName()]) < 1) {
                $mandatory = new ValidationError($field, 'is mandatory');
                $field->addError($mandatory);

                // Go to the next field, no need to validate
                continue;
            }

            $validationResult = $field->validate();

            if ($validationResult) {
                $validationError = new ValidationError($field);
                $field->addError($validationError);
            }
        }
    }
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;
    }
459605
protected function checkRequiredAttributes()
    {
        foreach ($this->getRequired() as $attribute) {
            if (is_null($this->get($attribute))) {
                throw new InvalidArgumentException(sprintf('"%s" cannot be empty.', $attribute));
            }
        }
    }
691375
public function validateOptions()
	{
		//override the config
		$this->validator->override($this->suppliedOptions, $this->rules);

		//if the validator failed, throw an exception
		if ($this->validator->fails())
		{
			throw new \InvalidArgumentException("There are problems with your '" . $this->suppliedOptions['action_name'] . "' action in the " .
									$this->config->getOption('name') . " model: " .	implode('. ', $this->validator->messages()->all()));
		}
	}
916504
public function check(...$args)
    {
        if (count($args) !== count($this->constraints)) {
            throw new InvalidArgumentException(
                'Argument number mismatch.'
            );
        }

        foreach ($args as $key => $arg) {
            if (!$this->constraints[$key]->check($arg, $args)) {
                throw new InvalidArgumentException(vsprintf(
                    'Argument %s does not meet its constraints.'
                    . "\nFailed constraint: %s\nValue provided:%s",
                    [
                        $key,
                        $this->constraints[$key]->toString(),
                        print_r($arg, true)
                    ]
                ));
            }
        }
    }
253723
public function setMinConstraint($minConstraint)
    {
        if (is_int($minConstraint) === false || $minConstraint < 0) {
            throw new InvalidArgumentException(
                "The 'minConstraint' argument must be a non negative (>= 0) integer."
            );
        }
        
        $this->minConstraint = $minConstraint;
    }
1017279
public function isValid() {
        $valid = TRUE;
        foreach ($this->fields as $key => $field) {

            // required
            if ($field->getOption("required") && $field->getValue() == "") {
                $this->errors[$key] = "Requerido";
                $valid = FALSE;
            }

            // custom validators
            if (isset($this->validators[$key])) {

                foreach ($this->validators[$key] as $validator) {

                    $validator->validate($field);
                    if (!$validator->isValid()) {
                        $this->errors[$key] = $validator->getMessage();
                        $valid = FALSE;
                    }
                }
            }
        }
        return $valid;
    }
27359
private function validate()
    {
        if ($this->hasValidated) {
            return;
        }

        $this->checkDepth();

        foreach ($this->schema as $rule => $parameter) {
            $this->currentKeyword   = $rule;
            $this->currentParameter = $parameter;
            $this->mergeErrors($this->validateRule($rule, $parameter));
            $this->currentKeyword = $this->currentParameter = null;
        }

        $this->hasValidated = true;
    }
792804
private function isRequired(Constraint $constraint): bool
    {
        foreach (self::REQUIRED_CONSTRAINTS as $requiredConstraint) {
            if ($constraint instanceof $requiredConstraint) {
                return true;
            }
        }

        return false;
    }
698851
public function check() {
        $this->_errors = [];

        foreach ($this->_constraints as $constraints) {
            if (!isset($this->_data[$this->_field])) {
                $this->_data[$this->_field] = [];
            }

            if (!is_array($this->_data[$this->_field])) {
                $this->_data[$this->_field] = [$this->_data[$this->_field]];
            }

            foreach ($this->_data[$this->_field] as $value) {
                switch ($constraints['type']) {
                    case self::EQUAL:
                        if ($value != $constraints['value']) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::DIFFERENT:
                        if ($value == $constraints['value']) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::MORETHAN:
                        if ($value <= $constraints['value']) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::LESSTHAN:
                        if ($value >= $constraints['value']) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::BETWEEN:
                        if ($value < $constraints['value'][0] || $value > $constraints['value'][1]) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::IN:
                        if (!in_array($value, $constraints['value'])) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::NOTIN:
                        if (in_array($value, $constraints['value'])) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::LENGTH:
                        if (strlen($value) != $constraints['value']) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::LENGTHMIN:
                        if (strlen($value) < $constraints['value']) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::LENGTHMAX:
                        if (strlen($value) > $constraints['value']) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::LENGTHIN:
                        if (!in_array(strlen($value), $constraints['value'])) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::LENGTHBETWEEN:
                        if (strlen($value) < $constraints['value'][0] || strlen($value) > $constraints['value'][1]) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::REGEX:
                        if (!preg_match($constraints['value'], $value)) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::URL:
                        if (!filter_var($value, FILTER_VALIDATE_URL)) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::MAIL:
                        if (!filter_var($value, FILTER_VALIDATE_EMAIL)) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::INT:
                        if (!filter_var($value, FILTER_VALIDATE_INT)) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::FLOAT:
                        if (!filter_var($value, FILTER_VALIDATE_FLOAT)) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::ALPHA:
                        if (!preg_match('#^([a-zA-Z]+)$#', $value)) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::ALPHANUM:
                        if (!preg_match('#^([a-zA-Z0-9]+)$#', $value)) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::ALPHADASH:
                        if (!preg_match('#^([a-zA-Z0-9_-]+)$#', $value)) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::IP:
                        if (!filter_var($value, FILTER_VALIDATE_IP)) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::SQL:
                        $sql = new Sql();
                        $sql->query('query-form-validation', $constraints['value']['query']);
                        $sql->vars('value', $value);
                        $sql->vars($constraints['value']['vars']);
                        $data = $sql->fetch('query-form-validation', Sql::PARAM_FETCHCOLUMN);

                        $querySuccess = true;

                        switch ($constraints['value']['constraint']) {
                            case '==':
                                if ($data != $constraints['value']['value']) {
                                    $querySuccess = false;
                                }
                                break;

                            case '!=':
                                if ($data == $constraints['value']['value']) {
                                    $querySuccess = false;
                                }
                                break;

                            case '>':
                                if ($data <= $constraints['value']['value']) {
                                    $querySuccess = false;
                                }
                                break;

                            case '<':
                                if ($data >= $constraints['value']['value']) {
                                    $querySuccess = false;
                                }
                                break;
                        }

                        if (!$querySuccess) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::CUSTOM:
                        /** @var object[] $constraints */
                        if ($constraints['value']->filter() == false) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['value']->error()]);
                        }
                        break;
                }
            }

            switch ($constraints['type']) {
                case self::COUNT:
                    if (count($this->_data[$this->_field]) != $constraints['value']) {
                        array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                    }
                    break;

                case self::COUNTMIN:
                    if (count($this->_data[$this->_field]) < $constraints['value']) {
                        array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                    }
                    break;

                case self::COUNTMAX:
                    if (count($this->_data[$this->_field]) > $constraints['value']) {
                        array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                    }
                    break;

                case self::COUNTIN:
                    /** @var array $constraints */
                    if (!in_array(count($this->_data[$this->_field]), $constraints['value'])) {
                        array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                    }
                    break;

                case self::EXIST:
                    if (count($this->_data[$this->_field]) == 0) {
                        array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                    }
                    break;

                case self::NOTEXIST:
                    if (count($this->_data[$this->_field]) > 0) {
                        array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                    }
                    break;
            }
        }
    }
1341258
public function validate()
    {
        $data = $this->wasSubmitted() === true ? $this->getSubmitted() : null;

        // Invalid selection on choice/multiple choice field
        if ($data === []) {
            $this->addError("Unrecognized choice.");
        }

        if ($this->isRequired() === true && $data === null) {
            $this->addError("This field is required.");
        }

        if ($this->getErrors() === []) {
            $this->setValidatedData($data);
        }
    }
1105028
public function validateArguments()
    {
        parent::validateArguments();

        if (empty($this->arguments['signature'])
            && (empty($this->arguments['extension']) || empty($this->arguments['main']) || empty($this->arguments['sub'])
            )
        ) {
            throw new \InvalidArgumentException('ifHasAccessToModule view helper requires either "signature" or all three other arguments: "extension", "main" and "sub". Please set arguments properly.', 1496314352);
        }
    }
506393
protected function checkConfiguration()
    {
        if (
            empty($this->config['name'])
            || empty($this->config['username'])
            || empty($this->config['host'])
        ) {
            throw new InvalidArgumentException(static::E_CONFIG);
        }
    }
900582
public function validate()
    {
        if ($this->isWorkflowDispatch() && null === $this->getWorkflowRunType()) {
            $errMsg = 'workflowRunType not specified';
            throw new Exception\InvalidMetadataException($errMsg);
        }

        if ($this->isFlagRunPrepareData()) {
            if (null === $this->getPrepareDataMethod()) {
                $errMsg = 'prepareDataMethod not specified';
                throw new Exception\InvalidMetadataException($errMsg);
            }
            if (null === $this->getPrepareDataMethod()) {
                $errMsg = 'prepareDataMethod not specified';
                throw new Exception\InvalidMetadataException($errMsg);
            }
        }

        if ($this->getFlagHasConditions()) {
            if (0 === count($this->getConditions())) {
                $errMsg = 'empty conditions';
                throw new Exception\InvalidMetadataException($errMsg);
            }

            foreach ($this->getConditions() as $condition) {
                $condition->validate();
            }
        }
    }