Get validation messages.

@param array $input

@return MessageBag|bool
966602
public function validationMessages($input)
    {
        $failedValidators = [];

        /** @var Field $field */
        foreach ($this->builder->fields() as $field) {
            if (!$validator = $field->getValidator($input)) {
                continue;
            }

            if (($validator instanceof Validator) && !$validator->passes()) {
                $failedValidators[] = $validator;
            }
        }

        $message = $this->mergeValidationMessages($failedValidators);

        return $message->any() ? $message : false;
    }
643054
public function validate($input): bool
    {
        // for array
        if (\is_array($input)) {
            return \in_array($this->containsValue, $input, true);
        }
        // for string
        if (\is_string($input)) {
            return false !== mb_strpos($input, $this->containsValue, 0, mb_detect_encoding($input));
        }
        return false;
    }
984899
public function check(array $input)
    {
        $missing = [];
        $invalid = [];

        $check = function ($constraint, $key, $value, $input) use (
            &$missing,
            &$invalid
        ) {
            if ($constraint instanceof AbstractConstraint) {
                if (!$constraint->check($value, $input)) {
                    $invalid[$key][] = $constraint;
                }
            } elseif ($constraint instanceof CheckableInterface) {
                $result = $constraint->check($value);

                $missing = Std::concat(
                    $missing,
                    array_map(
                        function ($subKey) use ($key) {
                            return vsprintf('%s.%s', [$key, $subKey]);
                        },
                        $result->getMissing()
                    )
                );

                foreach ($result->getFailed() as $failedField => $constraints) {
                    $fullPath = vsprintf('%s.%s', [$key, $failedField]);

                    if (array_key_exists($fullPath, $invalid)) {
                        $invalid[$fullPath] = array_merge(
                            $invalid[$fullPath],
                            $constraints
                        );
                    } else {
                        $invalid[$fullPath] = $constraints;
                    }
                }
            } else {
                throw new CoreException(
                    vsprintf(
                        'Unexpected constraint type: %s.',
                        [
                            TypeHound::fetch($constraint),
                        ]
                    )
                );
            }
        };

        $inputMap = ArrayMap::of($input);

        $this->annotations->each(
            function ($value, $key) use (
                $check,
                $input,
                $inputMap,
                &$missing
            ) {
                // If a field is required but not present, we should report it.
                if (Maybe::fromMaybe(
                        false,
                        $value->lookup(static::ANNOTATION_REQUIRED)
                    )
                    && $inputMap->member($key) === false
                ) {
                    $missing[] = $key;

                    // There's no point on checking constraints on the field
                    // since it is missing.
                    return;
                } elseif ($inputMap->member($key) === false) {
                    // There's no point on checking constraints on the field
                    // since it is missing.
                    return;
                }

                $fieldValue = Maybe::fromJust($inputMap->lookup($key));

                $this
                    ->getInternalFieldConstraints($key)
                    ->each(
                        function ($constraint) use (
                            $check,
                            $key,
                            $fieldValue,
                            $input
                        ) {
                            $check($constraint, $key, $fieldValue, $input);
                        }
                    );
            }
        );

        if (count($missing) === 0 && count($invalid) === 0) {
            return new SpecResult($missing, $invalid, SpecResult::STATUS_PASS);
        }

        return new SpecResult($missing, $invalid, SpecResult::STATUS_FAIL);
    }
176355
public function validate( $input )
    {
        $validatorClassNames = array();

        $validatorExceptions = array();

        foreach( $this->validators as $validator )
        {
            try {
                return $validator->validate( $input );
            } catch( phpillowValidationException $e ) {
                $validatorClassName                       = get_class( $validator );
                $validatorClassNames[]                    = $validatorClassName;
                $validatorExceptions[$validatorClassName] = $e;
            }
        }

        $exception = new phpillowValidationException(
            'Could not validate, as none of the given validators (%validators) validated the input.',
            array(
                'validators' => join( ',', $validatorClassNames )
            )
        );

        $exception->validatorExceptions = $validatorExceptions;

        throw $exception;
    }
240413
public function sanitize(array $input)
    {
        if (!isset($input['text'])) {
            throw new InvalidArgumentException('A \'text\' entry should have been given in the input array');
        }
        if (!is_object($input['text']) || !($input['text'] instanceof Text)) {
            throw new InvalidArgumentException('The \'text\' entry should be an instance of Text');
        }

        return $input['text'];
    }
821378
protected function validate($input, array &$messages)
    {
        $uniqueValues = [];

        foreach ($input as $element) {
            $uniqueValues[ValueHasher::hash($element)] = true;
        }

        if (count($uniqueValues) !== count($input)) {
            $messages[] = new Message(self::MESSAGE);
        }
    }
276922
private function getValidationMessages(array $validationData)
    {
        $messages = array();
        $messagesData = $validationData['messages'];
        foreach ($messagesData as $messageData) {
            $message = new W3CMarkupValidatorMessage($messageData);
            $messages[] = $message;
        }

        return $messages;
    }
1215511
public function validate( $input )
    {
        // Check if we received a unix timestamp, in this case we can just
        // directly convert and return it.
        if ( is_numeric( $input ) )
        {
            $date = new DateTime( '@' . $input );
            return $date->format( DATE_RFC2822 );
        }

        // Otherwise we received most presumably some phpillowrary string, which
        // we first just try to parse with datetime (strtotime).
        if ( ( $date = new DateTime( $input ) ) !== false )
        {
            return $date->format( DATE_RFC2822 );
        }

        // If DateTime could not parse the string, we got a problem. Maybe
        // handle more datetime formats here manually, but now we just fail.
        //
        // Since PHP 5.3 datetime seems to accept everything and just returns
        // NOW, if it fails to parse. So this seems untestable for now.
        throw new phpillowValidationException( 
            'Error parsing the date: %date', 
            array(
                'date' => $input,
            )
        );
    }
441432
public function onlyFillable(array $input)
    {
        $result = array_intersect_key($input, array_flip($this->modelInstance->getFillable()));

        foreach ($this->avoidEmptyUpdate as $avoid) {
            if (array_key_exists($avoid, $result) && empty($result[$avoid])) {
                unset($result[$avoid]);
            }
        }

        return $result;
    }
1269571
private function input() {
		if ($this->input===null) {
			$this->input=new ValidationInputOne($this->prefix,$this->messageList); // we used the same message list
		}
		return $this->input;
	}
987546
public function getMessageValidator(): ValidateMessage
    {
        $messageValidator = new ValidateMessageImplementation(
            [
                new CapitalizeTheSubjectLineValidator(),
                new DoNotEndTheSubjectLineWithAPeriodValidator(),
                new LimitTheBodyWrapLengthTo72CharactersValidator(),
                new LimitTheTitleLengthTo69CharactersValidator(),
                new SeparateSubjectFromBodyWithABlankLineValidator(),
                new SoftLimitTheTitleLengthTo50CharactersValidator(),
            ]
        );

        return $messageValidator;
    }
198675
public static function readMessage($input)
    {
        $line = fgets($input);
        $values = explode(':', $line);
        if (count($values) !== 2 || trim($values[0]) !== self::CONTENT_LENGTH) {
            return null;
        }
        $length = intval(trim($values[1]));

        // read one empty line.
        while (trim(fgets($input)) !== '') {}

        $json = fread($input, $length);
        return Common::decode($json);
    }
1144346
public function validate( $input ) 
    {
        if ( !is_array( $input ) ) 
        {
            throw new phpillowValidationException( 
                "Field is not an array",
                array()
            );
        }

        // Reuse the parent object validator foreach of the embedded objects
        foreach( $input as $key => $object ) 
        {
            $input[$key] = parent::validate( $object );
        }

        return $input;
    }
103626
protected function normalize(array $input) : array
    {
        $normalized = [];
        foreach ($this->rules() as $field => $value) {
            $normalized[$field] = $input[$field] ?? '';
        }
        return $normalized;
    }
308345
public function validate($input): bool
    {
        $this->error = null; // clean
        foreach ($this->rules as $rule) {
            if (!$rule->validate($input)) {
                // apply custom description or use description from rule
                $this->setError($this->description ?? $rule->getDescription());
                return false;
            }
        }
        return true;
    }
549130
public function validate($input): bool
    {
        if (\is_string($input)) {
            $input = trim($input);
        }

        return !empty($input);
    }
1282386
protected function validator($input)
    {
        $this->checkValue($input);

        if ($this->hasErrors()) {
            return '';
        }

        if (!$input) {
            if ($this->mandatory) {
                $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['mandatory'], $this->strLabel));
            }

            return '';
        } elseif (false === strpos($input, ',')) {
            return $this->multiple ? [(int) $input] : (int) $input;
        }
        $arrValue = array_map('intval', array_filter(explode(',', $input)));

        return $this->multiple ? $arrValue : $arrValue[0];
    }