Validate input has an extension and is in the whitelist.

@uses Titon\Utility\Loader

@param string $input
@param string|array $extensions
@return bool
330936
public static function ext($input, $extensions = array('gif', 'jpeg', 'png', 'jpg')) {
        if (is_array($input) && isset($input['name'])) {
            $input = $input['name'];
        }

        return in_array(Path::ext($input), (array) $extensions, true);
    }
199796
private static function isValid($input)
    {
        if (!is_array($input)) {
            return false;
        }
        foreach ($input as $value) {
            if (!is_scalar($value)) {
                return false;
            }
        }

        return true;
    }
297389
public static function for_extensions($extensions)
    {
        foreach ($extensions as $extension) {
            if ($formatter = self::for_extension($extension)) {
                return $formatter;
            }
        }

        return false;
    }
53472
protected function validMimeImageByExtension($extensions)
    {
        foreach (explode(',', $extensions) as $ext) {
            if (($mimes = $this->getMimeByExtension($ext)) === false) {
                return false;
            }
            $this->validMimeImage($ext, $mimes);
        }
    }
42165
public function validate(array $input, AppliesToResource $resource=null, $locale=null)
    {

        // If a generic validator didnt have a resource until here, assign it
        if (!$this->rules && $this instanceof GenericValidatorContract && !$this->resource()) {
            $this->setResource($resource);
        }

        $rules = $this->prepareRulesForValidation($this->rules(), $input, $resource, $locale);

        $this->callBeforeListeners('validate', [$input, $rules, $resource, $locale]);

        $validation = $this->performValidation($input, $rules, $resource, $locale);

        $this->callAfterListeners('validate', [$input, $rules, $resource, $validation, $locale]);

        if (count($validation)) {
            throw $validation;
        }

        return true;
    }
543796
public function validate($input): bool
    {
        if (!\is_array($input)) {
            return false;
        }
        $filtered = array_filter($input, $this->callback);
        return \count($input) === \count($filtered);
    }
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;
    }
594706
public function getValidator(array $input)
    {
        if ($this->validator) {
            return $this->validator->call($this, $input);
        }

        $rules = $attributes = [];

        if (!$fieldRules = $this->getRules()) {
            return false;
        }

        if (is_string($this->column)) {
            if (!array_has($input, $this->column)) {
                return false;
            }

            $input = $this->sanitizeInput($input, $this->column);

            $rules[$this->column] = $fieldRules;
            $attributes[$this->column] = $this->label;
        }

        if (is_array($this->column)) {
            foreach ($this->column as $key => $column) {
                if (!array_key_exists($column, $input)) {
                    continue;
                }
                $input[$column.$key] = array_get($input, $column);
                $rules[$column.$key] = $fieldRules;
                $attributes[$column.$key] = $this->label."[$column]";
            }
        }

        return Validator::make($input, $rules, $this->validationMessages, $attributes);
    }
930626
public function validate($field, $input, array $params = array())
    {
        try {
            if ($input == '' || empty($params['0'])) {
                return false;
            }
            $params = $params['0'];
            if (empty($params['gcs_access_key']) || empty($params['gcs_secret_key'])) {
                return false;
            }
            
            $client = m62Gcs::getRemoteClient($params['gcs_access_key'], $params['gcs_secret_key']);
            $client->listBuckets();
            return true;
        } catch (\Exception $e) {
            return false;
        }
    }
563038
function validateExtensions(input) {
  return new Promise((resolve, reject) => {
    try {
      const extensionPath = getExtensionsPath();

      if (!fs.existsSync(extensionPath)) {
        fs.mkdirSync(extensionPath);
      }

      if (!input.imports.length) {
        return resolve(null);
      }

      return resolve(input);
    } catch (e) {
      return reject(new Error(t('EXTENSION_COULD_NOT_BE_VALIDATED')));
    }
  });
}
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;
    }
178827
public function match($input)
    {
        if (!is_string($input)) {
            throw new \InvalidArgumentException(
                'Invalid argument. Expected a string, received ' . gettype($input)
            );
        }

        return (bool) preg_match('/' . $this->getRule() . '/ms', strtolower($input));
    }
600538
public function validate($input): bool
    {
        if (\is_array($this->haystack)) {
            return \in_array($input, $this->haystack, false);
        }

        if (!\is_string($this->haystack)) {
            return false;
        }

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

        $enc = mb_detect_encoding($input);

        return mb_stripos($this->haystack, $input, 0, $enc) !== 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;
    }
1004629
public static function hasExtension($baseName, array $extensions)
    {
        // Lowercase names
        $baseName = strtolower($baseName);

        $extensions = array_map(function($key){
            return strtolower($key);
        }, $extensions);

        return in_array(self::getExtension($baseName), $extensions);
    }
687123
protected function validate($input, array &$messages)
    {
        /** @var IUploadedFile $input */

        if (!$input->hasUploadedSuccessfully()) {
            if (!isset(self::$errorMap[$input->getUploadError()])) {
                throw InvalidArgumentException::format('Unknown file upload error: \'%s\'', $input->getUploadError());
            }

            $messages[] = new Message(self::$errorMap[$input->getUploadError()]);
        }
    }
433091
private function isValidExtension($extension, $base)
	{
		$ext = explode('_', $extension);
		$dir = '';

		switch ($ext[0])
		{
			case 'com':
				$dir = $base . DS . 'components' . DS . $extension;
			break;
			case 'mod':
				$dir = $base . DS . 'modules' . DS . $extension;
			break;
			case 'plg':
				$dir = $base . DS . 'plugins' . DS . $ext[1] . DS . $ext[2];
			break;
			default:
				return false;
			break;
		}

		return (is_dir($dir)) ? true : false;
	}