@param array                       $value
@param array                       $items
@param \League\JsonGuard\Validator $validator

@return \League\JsonGuard\ValidationError
342830
private static function validateAdditionalItemsWhenNotAllowed($value, $items, Validator $validator)
    {
        if (count($value) > count($items)) {
            return error('The array must not contain additional items.', $validator);
        }
    }
489822
public function validateSettings(array $settings, Validator $validator)
    {
        $handler = $this->get('handler');
        if (class_exists($handler)) {
            $handler = new $handler();

            return $handler->validateSettings($this, $settings, $validator);
        }
    }
911863
public function validateToArray($value, $constraints = null, $groups = null)
    {
        return $this->formatViolationsToArray($this->validate($value, $constraints, $groups));
    }
1010057
private static function validateAdditionalItemsAgainstSchema($items, $schema, Validator $validator)
    {
        $errors = [];
        foreach ($items as $key => $item) {
            $subValidator = $validator->makeSubSchemaValidator(
                $item,
                $schema,
                pointer_push($validator->getDataPath(), $key)
            );
            $errors = array_merge($errors, $subValidator->errors());
        }

        return $errors;
    }
1153024
public function validate($field, $value, $validator) {
		$value2 = $validator->get_data($this->compare_against);
		return $value === $value2;
	}
848658
public function validate($validator)
    {
        $values = $this->getValueArray();
        $validValues = $this->getValidValues();

        // Filter out selected values not in the data source
        $self = $this;
        $invalidValues = array_filter(
            $values,
            function ($userValue) use ($self, $validValues) {
                foreach ($validValues as $formValue) {
                    if ($self->isSelectedValue($formValue, $userValue)) {
                        return false;
                    }
                }
                return true;
            }
        );
        if (empty($invalidValues)) {
            return true;
        }

        // List invalid items
        $validator->validationError(
            $this->getName(),
            _t(
                'SilverStripe\\Forms\\MultiSelectField.SOURCE_VALIDATION',
                "Please select values within the list provided. Invalid option(s) {value} given",
                array('value' => implode(',', $invalidValues))
            ),
            "validation"
        );
        return false;
    }
1059952
protected function validateItem($key, $value): bool
    {
        // run validators chain
        $result = $this->validators[$key]->validate($value);

        if (!$result) {
            $this->exception->setError($key, $this->validators[$key]->getError());
        }

        return $result;
    }
714809
public function validateObjectFieldValue($value, $fieldName, $targetObject, &$validatorParams, $validatorKey) {

        if (sizeof($validatorParams) < ($this->mode == self::MODE_RANGE ? 2 : 1)) {
            throw new MisconfiguredValidatorException($validatorKey, $fieldName, $targetObject);
        }

        if (!$value) return true;

        switch ($this->mode) {
            case self::MODE_MIN:
                return strlen($value) >= $validatorParams[0];
            case self::MODE_MAX:
                return strlen($value) <= $validatorParams[0];
            case self::MODE_RANGE:
                return strlen($value) <= $validatorParams[1] && strlen($value) >= $validatorParams[0];
        }

    }
827935
private function validateItem($value, $rules)
    {
        if (!$value && strlen($value) == 0 && empty($rules['required'])) {
            return true;
        }

        //
        unset($rules['message'], $rules['trigger']);

        foreach ($rules as $ruleName => $ruleValue) {
            if (!call_user_func("static::{$ruleName}", $value, $ruleValue)) {
                return false;
            }
        }
    }
906252
public function validate(array $params, array $rules, array $messages = [])
    {
        $validator = app(Validator::class)->make($params, $rules, $messages);

        if ($validator->fails()) {
            throw new ValidationException(
                $validator, new JsonResponse($validator->errors()->getMessages(), 422)
            );
        }
    }
85119
public function checkbox($name = null, $value = null, $items = array()) 
	{
		Argument::i()
			->test(1, 'string', 'null')
			->test(2, 'scalar', 'array', 'null')
			->test(3, 'string', 'array');
		
		$field = Checkbox::i()->setItems($items);
		
		if(!is_null($name)) {
			$field->setName($name);
		}
		
		if(!is_null($value)) {
			$field->setValue($value);
		}
		
		return $field;
	}
1368747
protected function _addValidatorProps($validator = [])
    {
        foreach ($validator as $key => $value) {
            if (!isset($value) || empty($value)) {
                continue;
            }
            if ($key === 'rule' && is_array($value) && !is_callable($value)) {
                $this->_pass = array_slice($value, 1);
                $value = array_shift($value);
            }
            if (in_array($key, ['rule', 'on', 'message', 'last', 'provider', 'pass'])) {
                $this->{"_$key"} = $value;
            }
        }
    }
342784
public function validate($value)
    {
        $validators = $this->getValidators();
        if ($validators->count() > 0) {
            $result = null;
            foreach ($validators as $validator) {
                if ($result === null) {
                    $result = $validator->validate($value);
                } else {
                    $result->merge($validator->validate($value));
                }
            }
        } else {
            $result = new ErrorResult();
        }

        return $result;
    }
614088
public function validate($value)
    {
        if (!is_array($value)) {
            return Error::unit([ Error::NON_ARRAY ]);
        }

        $errors = [];
        foreach ($value as $pos => $item) {
            $result = parent::validate($item);
            if ($result instanceof Error) {
                $errors[$pos] = $result->unwrap();
            }
        }

        return empty($errors) ? Ok::unit() : Error::unit($errors);
    }
698635
public function select($name = null, $value = null, array $items = array()) 
	{
		Argument::i()
			->test(1, 'string', 'null')
			->test(2, 'scalar', 'null');
			
		$field = Select::i()->setItems($items);
		
		if(!is_null($name)) {
			$field->setName($name);
		}
		
		if(!is_null($value)) {
			$field->setValue($value);
		}
		
		return $field;
	}
196951
protected function validateCollectionTypeValue(array $structure, $value) : bool
    {
        $r = false;


        if ($structure["dataType"] === "type") {
            $nullable = (strpos($structure["structureType"], "nullable") === 0);


            if ($nullable === true && $value === null) {
                $r = true;
            } else {
                switch ($structure["internalStructure"]) {
                    case "mixed":
                        $r = true;
                        break;

                    case "?bool":
                    case "bool":
                        $r = (is_bool($value) === true);
                        break;

                    case "?int":
                    case "int":
                        $r = (is_int($value) === true);
                        break;

                    case "?float":
                    case "float":
                        $r = (is_float($value) === true);
                        break;

                    case "?string":
                    case "string":
                        $r = (is_string($value) === true);
                        break;

                    default:
                        $cname = $structure["internalStructure"];
                        $r = (is_a($value, $cname) === true || in_array($cname, class_implements($value)) === true);
                        break;
                }

                if ($r === false) {
                    $this->messageInvalidValue = "Invalid given value. Expected \"" . $this->collectionType . "\" .";
                }
            }
        } else {
            if ($structure["dataType"] === "array-of-types") {
                if (strpos($structure["structureType"], "nullable") === 0 && $value === null) {
                    $r = true;
                } elseif (is_array($value) === true && $this->isAssoc($value) === false) {
                    $childModels = $structure["childModel"];

                    foreach ($value as $i => $v) {
                        $r = $this->validateCollectionTypeValue($childModels[$i], $v);
                        if ($r === false) {
                            break;
                        }
                    }
                }
            } elseif ($structure["dataType"] === "array-assoc") {
                if (strpos($structure["structureType"], "nullable") === 0 && $value === null) {
                    $r = true;
                } elseif ($this->isAssoc($value) === true) {
                    $childModels = $structure["childModel"];
                    $key = array_keys($value)[0];
                    $val = $value[$key];

                    if (strpos($structure["structureType"], "nullable") === 0 && $val === null) {
                        $r = true;
                    } else {
                        $r = ($this->validateCollectionTypeValue($childModels[0], $key) === true &&
                            $this->validateCollectionTypeValue($childModels[1], $val) === true);
                    }
                }
            }
        }


        return $r;
    }
1200520
protected function applyValidator($validator, $key, $value, $messages = [])
    {
        try {
            if ($this->isString($validator)) {
                $params = $this->arr(explode(':', $validator));
                $vName = '';
                $validatorParams = [$this, $value, $params->removeFirst($vName)->val()];
                $validator = Entity::getInstance()->getValidator($vName);
                if (!$validator) {
                    throw new ValidationException('Validator does not exist');
                }
                $validator->validate(...$validatorParams);
            } elseif ($this->isCallable($validator)) {
                $vName = 'callable';
                $validator($value, $this);
            }
        } catch (ValidationException $e) {
            $msg = isset($messages[$vName]) ? $messages[$vName] : $e->getMessage();

            $ex = new ValidationException($msg);
            $ex->addError($key, $msg);

            throw $ex;
        }
    }