Check input data

@param  mixed $input

@return bool
549130
public function validate($input): bool
    {
        if (\is_string($input)) {
            $input = trim($input);
        }

        return !empty($input);
    }
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;
    }
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;
    }
1336715
public function validate($input): bool
    {
        if (is_array($input) === false && ($input instanceof Generator) === false) {
            throw new InvalidArgumentException();
        }

        if ($this->areAggregatorsDirty() === true) {
            $this->resetAggregators();
        }

        $this->validateAttributes($input)->markAggregatorsAsDirty();

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

        return $hasNoErrors;
    }
1202072
protected function scan( $input )
	{
		static $regex;
		if ( !isset( $regex ) )
		{
			$regex = sprintf( '/(%s)|%s/%s', implode( ')|(', $this->getCatchablePatterns() ), implode( '|', $this->getNonCatchablePatterns() ), $this->getModifiers() );
		}
		$flags = PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE;
		$matches = preg_split( $regex, $input, -1, $flags );
		foreach ( $matches as $match )
		{
			// Must remain before 'value' assignment since it can change content
			$type = $this->getType( $match[0] );
			$this->tokens[] = [
				'value' => $match[0],
				'type' => $type,
				'position' => $match[1],
			];
		}
	}
1169527
public static function receive($input = null)
    {
        if (is_null($input)) {
            if (self::$receivedWebhook !== null) {
                $input = self::$receivedWebhook;
            } else {
                $input = file_get_contents("php://input");
            }
        }

        if (!is_null($input) && $input != '') {
            return self::processWebhook($input);
        }

        return false;
    }
523120
public static function attempt($input)
    {
        $userModel = Config::get('user');
        $model = new $userModel();

        $count = 0;

        foreach ($input as $field => $value) {
            if ($field == '_') {
                unset($input[$field]);
            } else {
                $count++;
            }
            if ($count == 1) {
                $primary = $field;
            }
        }

        if (!empty($input)) {
            $user = $model->where($primary, $input[$primary])->first();

            if (! empty($user) && Hash::check($input['password'], $user->password)) {
                Session::set('user', $user->id);
                return true;
            }

            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);
    }
1006208
public static function clearInput($input)
    {
        if (is_array($input)) {
            foreach ($input as $key => $value) {
                if (!isset($value) || $value === '') {
                    unset($input[$key]);
                }
            }

            return $input;
        }

        return $input;
    }
29090
private function verifyMod10($input): bool
    {
        $sum = 0;
        $input = strrev($input);
        $inputLen = \strlen($input);
        for ($i = 0; $i < $inputLen; $i++) {
            $current = $input[$i];
            if ($i % 2 === 1) {
                $current *= 2;
                if ($current > 9) {
                    $firstDigit = $current % 10;
                    $secondDigit = ($current - $firstDigit) / 10;
                    $current = $firstDigit + $secondDigit;
                }
            }
            $sum += $current;
        }

        return ($sum % 10 === 0);
    }
1011414
public function ok(&$input): bool
    {
        $input = trim((string) $input);
        $inputLabel = trim($this->fieldLabel ?: 'Field');

        // check required issue
        if ($input === '' && $this->isRequired) {
            $this->fail = sprintf('%s is required.', $inputLabel);
            return false;
        }

        // assing default to input but do not return
        // true to check also given default
        if ($input === '') {
            $input = $this->fieldDefault;
        }

        // skip if null given as default
        // that also checks given default
        if ($input === null && !$this->isRequired) {
            return true;
        }

        // valide by field type
        switch ($this->fieldType) {
            case Validation::TYPE_INT:
            case Validation::TYPE_FLOAT:
                if (!is_numeric($input)) {
                    $this->fail = sprintf('%s value must be type of %s.', $inputLabel, $this->fieldType);
                    return false;
                }

                // sanitize
                $input = ($this->fieldType == Validation::TYPE_INT) ? intval($input) : floatval($input);

                // make unsigned
                if ($this->isUnsigned) {
                    $input = abs($input);
                }

                // check limit(s)
                if ($this->limit !== null) {
                    if (is_numeric($this->limit) && strval($input) !== strval($this->limit)) {
                        $this->fail = sprintf('%s value could be only %s.', $inputLabel, $this->limit);
                        return false;
                    }
                    if ($this->limitMin !== null && $input < $this->limitMin) {
                        $this->fail = sprintf('%s value could be minimum %s.', $inputLabel, $this->limitMin);
                        return false;
                    }
                    if ($this->limitMax !== null && $input > $this->limitMax) {
                        $this->fail = sprintf('%s value could be maximum %s.', $inputLabel, $this->limitMax);
                        return false;
                    }
                }
                break;
            case Validation::TYPE_NUMERIC:
                if (!is_numeric($input)) {
                    $this->fail = sprintf('%s value must be numeric.', $inputLabel);
                    return false;
                }
                // make unsigned
                if ($this->isUnsigned) {
                    $input = abs($input);
                }
                break;
            case Validation::TYPE_STRING:
                // check regexp if provided
                if ($this->specType == 'regexp' && !preg_match($this->spec, $input)) {
                    $this->fail = sprintf('%s value did not match with given pattern.', $inputLabel);
                    return false;
                }

                // check limit(s)
                if ($this->limit !== null) {
                    $isNumericLimit = is_numeric($this->limit);
                    // should truncate?
                    if ($this->isFixed) {
                        $input = mb_substr($input, 0, intval($isNumericLimit ? $this->limit : $this->limitMax));
                    }

                    $inputLength = strlen($input);
                    if ($isNumericLimit && $inputLength !== $this->limit) {
                        $this->fail = sprintf('%s value length must be %s.', $inputLabel, $this->limit);
                        return false;
                    }
                    if ($this->limitMin !== null && $inputLength < $this->limitMin) {
                        $this->fail = sprintf('%s value minimum length could be %s.', $inputLabel, $this->limitMin);
                        return false;
                    }
                    if ($this->limitMax !== null && $inputLength > $this->limitMax) {
                        $this->fail = sprintf('%s value maximum length could be %s.', $inputLabel, $this->limitMax);
                        return false;
                    }
                }
                break;
            case Validation::TYPE_BOOL:
                // set default bool spec
                if ($this->specType != 'array') {
                    $this->spec = ['true', 'false'];
                }

                if (!in_array($input, $this->spec)) {
                    $this->fail = sprintf('%s value could be one of %s options.', $inputLabel, join(', ', $this->spec));
                    return false;
                }
                break;
            case Validation::TYPE_ENUM:
                // @todo Multi-arrays?
                if (!in_array($input, $this->spec)) {
                    $this->fail = sprintf('%s value could be one of %s options.', $inputLabel, join(', ', $this->spec));
                    return false;
                }
                break;
            case Validation::TYPE_EMAIL:
                if (!filter_var($input, FILTER_VALIDATE_EMAIL)) {
                    $this->fail = sprintf('%s value must be a valid email address.', $inputLabel);
                    return false;
                }
                break;
            case Validation::TYPE_DATE:
            case Validation::TYPE_DATETIME:
                if ($this->specType == 'regexp' && !preg_match($this->spec, $input)) {
                    $this->fail = sprintf('%s value did not match with given pattern.', $inputLabel);
                    return false;
                }

                if ($input != date($this->spec, strtotime($input))) {
                    $this->fail = sprintf('%s value is not valid date/datetime.', $inputLabel);
                    return false;
                }
                break;
            case Validation::TYPE_URL:
                if ($this->specType == 'regexp' && !preg_match($this->spec, $input)) {
                    $this->fail = sprintf('%s value did not match with given pattern.', $inputLabel);
                    return false;
                }
                if ($this->specType == 'array') {
                    // remove silly empty components (eg: path always comes even url is empty)
                    $url = array_filter((array) parse_url($input), 'strlen');
                    $components = [];
                    foreach ($this->spec as $component) {
                        if (!isset($url[$component])) {
                            $components[] = $component;
                        }
                    }
                    if (!empty($components)) {
                        $this->fail = sprintf('%s value is not a valid URL (missing components: %s).',
                            $inputLabel, join(', ', $components));
                        return false;
                    }
                    return true;
                }
                if (!filter_var($input, FILTER_VALIDATE_URL)) {
                    $this->fail = sprintf('%s value is not a valid URL.', $inputLabel);
                    return false;
                }
                break;
        }

        // seems nothing wrong
        return true;
    }
1182730
public static function is( $input, bool $simple = false ): bool {
    if( is_int( $input ) || is_float( $input ) ) return true;
    else if( !$simple ) {

      if( is_bool( $input ) ) return true;
      else if( Text::is( $input, true ) ) return strlen( $input ) > 0 && ltrim( $input, '+-,.e0123456789' ) == '';
    }

    return false;
  }
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;
    }
358113
public function validate($input)
    {
        $checkDigit = explode(',', '0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,h,j,k,l,m,n,p,r,s,t,u,v,w,x,y');

        // Get the check digit
        $check = strtolower(substr($input, -1, 1));

        // Remove dash, plus or A
        if (strlen($input) == 11) {
            $input = substr($input, 0, 6) . substr($input, 7, 3);
        } else {
            $input = substr($input, 0, 9);
        }

        if (!preg_match('/^\d+$/', $input)) {
            return false;
        }

        // Do the math
        $result = $input % 31;

        return $checkDigit[$result] == $check;
    }
1126986
public function validate($input): bool
    {
        return $this->less($this->minValue, $input)
            && $this->less($input, $this->maxValue);
    }
165024
protected function detectSpecialKey($input)
    {
        $specialKey = false;
        if (in_array(ord($input), [27, 127, 10])) {
            $specialKey = array_search(urlencode($input), $this->specialKeys);
        }

        return $specialKey ? $specialKey : null;
    }
192644
private function checkAttributes($input)
    {
        if (!$this->hasValidStructure($input)) {
            $unknown = $this->checkValidStructure($input);

            $params = [];
            if (count($unknown) !== 0) {
                $params['attributes'] = $unknown;
            }
            $exception = $this->reportError($input, $params);

            throw $exception;
        }
    }