Get validator for this field.

@param array $input

@return bool|Validator
492598
public function getValidator(array $input)
    {
        if (!array_key_exists($this->column, $input)) {
            return false;
        }

        $input = Arr::only($input, $this->column);

        $form = $this->buildNestedForm($this->column, $this->builder);

        $rules = $attributes = [];

        /* @var Field $field */
        foreach ($form->fields() as $field) {
            if (!$fieldRules = $field->getRules()) {
                continue;
            }

            $column = $field->column();

            if (is_array($column)) {
                foreach ($column as $key => $name) {
                    $rules[$name.$key] = $fieldRules;
                }

                $this->resetInputKey($input, $column);
            } else {
                $rules[$column] = $fieldRules;
            }

            $attributes = array_merge(
                $attributes,
                $this->formatValidationAttribute($input, $field->label(), $column)
            );
        }

        Arr::forget($rules, NestedForm::REMOVE_FLAG_NAME);

        if (empty($rules)) {
            return false;
        }

        $newRules = [];
        $newInput = [];

        foreach ($rules as $column => $rule) {
            foreach (array_keys($input[$this->column]) as $key) {
                $newRules["{$this->column}.$key.$column"] = $rule;
                if (isset($input[$this->column][$key][$column]) &&
                    is_array($input[$this->column][$key][$column])) {
                    foreach ($input[$this->column][$key][$column] as $vkey => $value) {
                        $newInput["{$this->column}.$key.{$column}$vkey"] = $value;
                    }
                }
            }
        }

        if (empty($newInput)) {
            $newInput = $input;
        }

        return Validator::make($newInput, $newRules, $this->validationMessages, $attributes);
    }
80886
public function validate($input): bool
    {
        if (\is_string($input) && filter_var($input, FILTER_VALIDATE_EMAIL)) {
            [, $domain] = explode('@', $input, 2);
            if ($this->checkDns) {
                return checkdnsrr($domain, 'MX') || checkdnsrr($domain, 'A');
            }
            return true;
        }
        return false;
    }
87701
public function validate($input) {
        if (is_null($input)) {
            return false;
        }
        if (is_string($input)) {
            return trim($input) !== '';
        }
        if (!is_array($input)) {
            return true;
        }
        foreach ($input as $item) {
            if ($this->validate($item)) {
                return true;
            }
        }
        return false;
    }
605217
public function parse(array $input): bool
    {
        $this->resetAggregators();

        $this
            ->validateType($input)
            ->validateId($input)
            ->validateAttributes($input)
            ->validateRelationships($input);

        $hasNoErrors = $this->getJsonApiErrorCollection()->count() <= 0;

        return $hasNoErrors;
    }
1222881
protected function validate(string $input): bool
    {
        return \Normalizer::isNormalized($input, \Normalizer::FORM_KC)
            && ($this->isRegExp($input) ? $this->validateRegexp($input) : $this->validateCharacters($input));
    }
870509
public function validate( $input )
    {
        $uuidv4Pattern = '(^([0-9a-fA-F]{8})-?([0-9a-fA-F]{4})-?(4[0-9a-fA-F]{3})-?([89abAB][0-9a-fA-F]{3})-?([0-9a-fA-F]{12})$)';
        if ( preg_match( $uuidv4Pattern, $input, $matches ) !== 1 ) 
        {
            throw new phpillowValidationException( 
                'A uuid version 4 is required. Something else has been given.',
                array()
            );
        }

        return strtolower( 
            $matches[1] . '-' . $matches[2] . '-' . $matches[3] . '-' . $matches[4] . '-' . $matches[5]
        );
    }
1024386
public function process(array $input)
    {
        try
        {
            $success = $this->v->validate($input);
        }
        catch(ValidationException $e)
        {
            $this->setErrorsAndThrowException();
        }
        if( ! $success)
        {
            $this->setErrorsAndThrowException();
        }

        Event::fire("form.processing", array($input));
        return $this->callRepository($input);
    }
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,
            )
        );
    }
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);
    }
1235278
public function getType($input)
    {
        // Make an array to loop through
        $inputs = explode('|', $input);

        foreach ($inputs as $index => $input) {
            $list = (bool) preg_match('/\[\]$/', $input);
            if ($list === true) {
                $input = substr($input, 0, -2);
            }

            // make the type case insensitive
            $type = strtolower(trim($input));

            // Check if we can convert the type to a known type
            if (array_key_exists($type, $this->phpTypeMapping) === true) {
                $type = $this->phpTypeMapping[$type];
            }

            // Check if it is a predefined type
            if (in_array($type, $this->phpTypes) === true) {
                $inputs[$index] = $type . ($list ? '[]' : '');
                continue;
            }

            // Reset the type. Maybe it is a class definition
            $type = $input;

            if (
                $this->isClassDefined($type) === true ||
                $this->isInterfaceDefined($type) === true ||
                $this->isTraitDefined($type) === true
            ) {
                $inputs[$index] = $type . ($list ? '[]' : '');
                continue;
            }

            throw Exception\Type::isNotDefined($type);
        }

        return implode('|', $inputs);
    }
505615
public function validate($input): bool
    {
        if ($this->areAggregatorsDirty() === true) {
            $this->resetAggregators();
        }

        $this->validateSingleImplementation($input, $this->getCaptureAggregator(), $this->getErrorAggregator());
        $this->markAggregatorsAsDirty();

        $noErrors = $this->getErrorAggregator()->count() <= 0;

        return $noErrors;
    }
1109229
public function verifySalt($input)
    {
        $appearsValid = (1 === preg_match('/^_[\.\/0-9A-Za-z]{8}$/', $input));
        if ($appearsValid) {
            $costFactor = $this->_decodeInt24(substr($input, 1, 4));
            if ($costFactor < 1 || $costFactor > (1 << 24) - 1) {
                $appearsValid = false;
            }
        }

        return $appearsValid;
    }
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;
    }
1035784
public function sanitizeInput(array $input)
    {
        return $input = collect($input)->reject(function ($value) {
            return is_null($value) || empty($value);
        })->toArray();
    }
1066010
public static function toObject($input = false) {

        if ($input) {

            switch (Data::type($input)) {
                case 'array':
                    $object = self::arrayToObject($input);
                    break;
                case 'object':
                    $object = $input;
                    break;
            }

            if (Validate::isObject($object)) {

                return $object;
            }
        }

        return false;
    }
1284450
protected function cleanInputData(array $input)
    {
        $columns = $this->getColumns();
        foreach ($columns as $column) {
            if (!isset($input[$column])) {
                $input[$column] = '';
            }
        }
        return $input;
    }
939596
protected function authenticate(array $input)
    {
        $remember = (($input['remember'] ?? 'no') === 'yes');

        $data = Arr::except($input, ['remember']);

        // We should now attempt to login the user using Auth class. If this
        // failed simply return false.
        return $this->auth->attempt($data, $remember);
    }