(non-PHPdoc)

@ignore

@see \mithra62\Validate\RuleInterface::validate()
508394
public function validate($field, $input, array $params = array())
    {
        try {
            if ($input == '' || empty($params['0'])) {
                return false;
            }
            
            $params = $params['0'];
            if (empty($params['rcf_username']) || empty($params['rcf_api']) || empty($params['rcf_container'])) {
                return false;
            }
            
            $local = new Remote(new Local(dirname($this->getTestFilePath())));
            $client = Rcf::getRemoteClient($params, true);
            if ($client instanceof \OpenCloud\ObjectStore\Resource\Container) {
                $contents = $local->read($this->test_file);
                $filesystem = new Remote(new Rcf($client, $params['rcf_container']));
                
                if ($filesystem->has($this->test_file)) {
                    $filesystem->delete($this->test_file);
                } else {
                    if ($filesystem->write($this->test_file, $contents)) {
                        $filesystem->delete($this->test_file);
                    }
                }
                
                return true;
            }
        } catch (\Exception $e) {
            return false;
        }
    }
677398
protected function _validate($value)
    {
        $ret = parent::_validate($value);

        if ($ret) {
            if (strlen($value) < self::$MIN_LENGTH) {
                $ret = false;
            }
        }

        return $ret;
    }
636910
public function validate($value)
    {
        $this->requiredCountOfAnyOf = count($this->allOf);

        return parent::validate($value);
    }
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;
    }
954637
public function validate($rules = [], $errors = [])
    {
        foreach ($rules as $param => $subRules) {
            $paramValue = $this->getParam($param);
            foreach ($subRules as $key => $rule) {
                $isError = false;
                if (!is_array($rule)) {
                    switch ($rule) {
                        case self::VALIDATE_REQUIRED:
                            if (is_null($paramValue)) {
                                $isError = true;
                            }
                            break;
                        case self::VALIDATE_MOBILE:
                            if (!ValidationHelper::isMobile($paramValue)) {
                                $isError = true;
                            }
                            break;
                    }
                } else {
                    switch ($key) {
                    case self::VALIDATE_ENUM:
                        if (!in_array($paramValue, $rule)) {
                            $isError = true;
                        }
                        break;
                    }
                }
                if ($isError) {
                    $errCode = self::ERROR_INVALID_PARAM;
                    $errMsg = self::errorMsg[self::ERROR_INVALID_PARAM];
                    if (is_array($rule)) {
                        $rule = $key;
                    }
                    if (isset($errors[$param][$rule]['code'])) {
                        $errCode = $errors[$param][$rule]['code'];
                    }
                    if (isset($errors[$param][$rule]['msg'])) {
                        $errMsg = str_replace('{param}', $param, $errors[$param][$rule]['msg']);
                    }
                    throw new ParamException($errMsg, $errCode);
                }
            }
        }
    }
1185756
protected function validate(InputInterface $input)
    {
        $host = $input->getArgument('host') ? $input->getArgument('host') : null;
        $ip = $input->hasArgument('ip') ? $input->getArgument('ip') : null;

        $this->hostFile->validate($host, $ip);
    }
1237197
public function validate()
    {
        foreach ($this->getFields() as $field) {
            if (! isset($this->submittedData[$field->getName()])) {
                continue;
            }
            
            // is it mandatory and empty?
            if ($field->isMandatory() && strlen($this->submittedData[$field->getName()]) < 1) {
                $mandatory = new ValidationError($field, 'is mandatory');
                $field->addError($mandatory);

                // Go to the next field, no need to validate
                continue;
            }

            $validationResult = $field->validate();

            if ($validationResult) {
                $validationError = new ValidationError($field);
                $field->addError($validationError);
            }
        }
    }
841269
protected function _validate($value)
    {
        $value = trim(str_replace('\\', '/', $value));
        return (is_string($value) && (preg_match(self::PATTERN, $value)) == 1);
    }
259141
public function validate()
    {
        $this->debug->groupCollapsed(__METHOD__, $this->attribs['name']);
        $this->props['isValid'] = true;
        $this->classRemove($this->props['attribsContainer'], 'has-error');
        $attribs = $this->attribs;
        if (\in_array($attribs['type'], array('checkbox','radio','select'))) {  // these types use the 'options' array
            $this->validateCrs();
        } elseif (\in_array($attribs['type'], array('submit','reset','image'))) {
            $this->debug->log('not checking');
        } elseif (!empty($this->props['newPage'])) {
            $this->debug->log('not checking newPage');
        } elseif (\in_array($attribs['type'], array('file'))) {
            $this->debug->log($attribs['name'].' is a file type');
            if ($this->isRequired() && empty($attribs['disabled']) && empty($attribs['value'])) {
                $this->flag();
            }
        } elseif ($this->isRequired() || $this->props['flagNonReqInvalid']) {
            if (!empty($attribs['placeholder']) && $attribs['value'] === $attribs['placeholder']) {
                $this->debug->log('value == placeholder');
                $attribs['value'] = null;
            }
            $this->validateFromAttributes();
        }
        if ($this->props['isValid']) {
            $isValid = $this->doValidate();
            // validate callback may call flag() directly
            if ($this->props['isValid'] && !$isValid) {
                $this->flag();
            }
        }
        $this->debug->groupEnd();
        return $this->props['isValid'];
    }
789454
public function validate()
    {
        foreach($this->rules() as $key => $value) {
            $this->rules[$key] =  [$this->input($key), $value];
        }

        $validate = $this->validator->validate($this->rules);

        if ($validate->fails()) {
            if($this->isAjax()) {
                return $this->response->json(['errors' => $validate->errors()->all()], 403);
            }

            return $this->redirect->backWith('errors', $validate->errors()->all());
        }
    }
27467
public function validate($input) {
        if (is_integer($input)) {
            return $this->validateMax($input) && $this->validateMin($input);
        }
        return $input == intval($input) && $this->validateMax($input) && $this->validateMin($input);
    }
1299612
public function validate(string $value)
    {
        if (!$value || $this->value === $value) {
            return;
        }

        $this->error['match'] = [$this->value];
    }
1151078
public function validate()
    {
        $globalValid = false;
        $localValid  = $this->validateOwner();
        foreach ($this->chainedRules as $item) {
            foreach ($item as $multiplier) {
                if (!($localValid = $localValid && $multiplier->validate())) {
                    break;
                }
            }
            if ($globalValid = $globalValid || $localValid) {
                break;
            }
            $localValid = true;
        }
        $globalValid or $this->setOwnerError();
        return $globalValid;
    }
1055481
public function validate($value) {
        // Sadly php bug #67167 makes the following lines necessary
        if(is_null($value)) {
            return new ValidationResult(false, 'Not a valid boolean but NULL', self::ERR_NULL);
        }
        if(is_object($value)) {
            return new ValidationResult(false, 'Not a valid boolean but an object', self::ERR_OBJECT);
        }
        
        if(filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE)===null) {
            return new ValidationResult(false, 'Not a valid boolean', self::ERR_NOBOOLEAN);
        }        
        return new ValidationResult(true);
    }
366716
public static function isValid($validator, $value)
    {
        /** @var ValidatorInterface $validator */
        $validator = static::create($validator);
        $result = $validator->isValid($value);
        static::$_messages = $validator->getMessages();
        return $result;
    }
1305595
public function validate($failOn = Validator\Rule::ERROR)
    {
        $this->warnings = [];
        $this->errors = [];

        foreach ($this->rules as $rule) {

            if ($rule instanceof Validator\Condition) {
                // Condition

                $condition = $rule;
                if ($condition->validate()) {
                    // Conditions rules

                    if (!$condition->getValidator()->validate($failOn)) {

                        $this->errors = array_merge(
                            $this->errors,
                            $rule->getValidator()->getErrors()
                        );
                    }
                    $this->warnings = array_merge(
                        $this->warnings,
                        $rule->getValidator()->getWarnings()
                    );
                }
            } else {
                // Rule

                if (!$rule->validate()) {

                    if ($rule->getSeverity() <= $failOn) {
                        $this->errors[] = $rule;
                    } else {
                        $this->warnings[] = $rule;
                    }
                }
            }
        }

        // Run nested validators - every entity may have its own validator
        foreach ($this->entity->getData() as $propertyName => $value) {

            if ($value instanceof Entity) {

                $validator = $value->getValidator();

                if (!$validator->validate($failOn)) {

                    foreach ($validator->getErrors() as $error) {

                        $rule = clone $error;
                        $rule->setPath(
                            array_merge([$propertyName], $rule->getPath())
                        );
                        $this->errors[] = $rule;
                    }
                }

                foreach ($validator->getWarnings() as $warning) {

                    $rule = clone $warning;
                    $rule->setPath(
                        array_merge([$propertyName], $rule->getPath())
                    );
                    $this->warnings[] = $rule;
                }
            }
        }

        return count($this->errors) === 0;
    }
129772
public function doValidate()
    {
        $isValid = true;
        if ($this->props['validate']) {
            $isValid = \call_user_func($this->props['validate'], $this);
        }
        return $isValid;
    }