Validate form

@return boolean
420689
private function validate()
    {
        if (!$this->cfg['validate']) {
            return true;
        }
        $formIsValid = true;
        foreach ($this->currentFields as $field) {
            $isValid = $field->validate();
            $formIsValid = $formIsValid && $isValid;
        }
        return $formIsValid;
    }
111065
protected function validate()
    {
        if (!CommonUtils::isRegexExpr($this->pattern)) {
            return false;
        }

        return (bool) preg_match(
            $this->pattern,
            $this->getRequestValue()
        );
    }
926865
public function isValid() {
		
		$valid = TRUE;
		
		foreach ($this->controls as $control) {
			
			if (!$control->validate()) {
				$valid = FALSE;
			}
			
		}
		
		return $valid;
		
	}
1111128
public function validate(& $form) {
		if (empty($_FILES['import_file']) || $_FILES['import_file']['error'] != UPLOAD_ERR_OK) {
			$form->error(DANGER, \Object\Content\Messages::REQUIRED_FIELD, 'import_file');
			return;
		}
		// process extension
		$extension = pathinfo($_FILES['import_file']['name'], PATHINFO_EXTENSION);
		$format = \Object\Content\ImportFormats::getStatic([
			'where' => [
				'extension' => $extension
			],
			'single_row' => true
		]);
		if (empty($format)) {
			$form->error(DANGER, 'Uknown file format!', 'import_file');
			return;
		}
		// import file
		$import_model = new \Numbers\Backend\IO\Common\Base();
		$temp = $import_model->import($format['format'], $_FILES['import_file']['tmp_name'], ['process_keys_and_values' => true]);
		if (!$temp['success']) {
			$form->error(DANGER, 'Could not read file!', 'import_file');
			return;
		}
		// process imported data
		$result = $form->import_object->processImportedSheets($temp['data'], $form->values);
		if (!$result['success']) {
			$form->error(DANGER, $result['error']);
			return;
		}
		// run imported data through form
		$messages = [
			'success' => 0,
			'error' => 0,
			'errors' => []
		];
		foreach ($result['data'] as $k => $v) {
			$v[\Object\Form\Parent2::BUTTON_SUBMIT_SAVE] = true;
			$form->import_object->addInput($v);
			$form->import_object->process();
			$temp = $form->import_object->apiResult();
			if (!$temp['success']) {
				$messages['error']++;
				$messages['errors'] = array_merge($messages['errors'], $temp['error']);
			} else {
				$messages['success']++;
			}
		}
		// print messages
		if (!empty($messages['success'])) {
			$form->error(SUCCESS, 'Successfully created/updated [number] records!', null, ['replace' => [
				'[number]' => i18n(null, $messages['success'])
			]]);
		}
		if (!empty($messages['error'])) {
			$form->error(DANGER, 'Could not import [number] records!', null, ['replace' => [
				'[number]' => i18n(null, $messages['error'])
			]]);
		}
		if (!empty($messages['errors'])) {
			foreach ($messages['errors'] as $v) {
				$v = str_replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;", $v);
				$v = str_replace("\n", "<br/>", $v);
				$form->error(DANGER, $v, null, ['skip_i18n' => true]);
			}
		}
	}
1165983
public function validate()
	{
		$varValue = $this->getPost($this->strName);

		if (!empty($varValue) && !$this->isValidOption($varValue))
		{
			$this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['invalid'], (is_array($varValue) ? implode(', ', $varValue) : $varValue)));
		}

		parent::validate();
	}
630815
public function validate()
	{
		try
		{
			Yaml\Yaml::parse($this->data);

		} catch(\Exception $e)
		{
			return false;
		}

		return true;
	}
806001
protected function isValid()
    {
        if (!$this->request->ajax()) {
            return false;
        }
        $search = $this->request->input('search');
        if (!is_string($search) or strlen($this->request->input('search')) <= 0) {
            return false;
        }
        $token = $this->request->header('search-protection');
        if (!$this->validateToken($token)) {
            return false;
        }
        return true;
    }
607029
public function isValid()
    {
        $result = true;
        $fields = $this->getFields();
        // Check each element for validators, validate them and return the result.
        foreach ($fields as $field) {
            if ($field->validate() == false) {
                $result = false;
            }
        }
        return $result;
    }
493546
protected function validate()
    {
        // If attributes are set, validate them.
        if (!empty($this->attributes)) {
            // It's possible that there are no rules for the attributes available.
            // If so, skip attribute validation.
            if (sizeof($this->getAttributeRules()) > 0) {
                $validate_attributes = new Validator($this->attributes);
                $validate_attributes->rules($this->getAttributeRules());

                // Validation failed to succeeed, show errors
                if (!$validate_attributes->validate()) {
                    echo 'Some attributes failed to pass the validator:';
                    foreach ($validate_attributes->errors() as $failed_attr) {
                        echo ' '. $failed_attr[0];
                    }
                    return false;
                }
            }
        }

        // If a value is set, validate it.
        if (array_key_exists('value', $this)) {
            // It's possible that there is no value rule set.
            // If so, skip value validation.
            if (sizeof($this->getValueRule()) > 0) {
                $validate_value = new Validator(['value' => $this->value]);
                $validate_value->rules($this->getValueRule());

                // Validation failed to succeeed, show errors
                if (!$validate_value->validate()) {
                    echo "The 'value' failed to pass the validator:";
                    foreach ($validate_value->errors() as $message) {
                        if (is_array($message)) {
                            $message = implode(',', $message);
                        }
                        echo ' '. strtolower($message);
                    }
                    return false;
                }
            }
        }

        return true;
    }
344008
public function validate()
    {
        $confirmationInput = $this->inputName.'_confirmation';

        if (isset($this->input[$confirmationInput]) &&
            $this->input[$confirmationInput] == $this->getValue()) {
            return true;
        }

        return false;
    }
1040684
public function validate()
    {
        $this->_errors = [];
        $success = true;
        foreach ($this->fields as $name => $field) {
            /** @var $field Field */
            if (!$field->validate($this, $this->getExtraValidatorFor($name))) {
                $success = false;
            }
        }

        return $success && count($this->_errors) === 0;
    }
932048
public function validate()
    {
        $errors = [];

        foreach ($this->fields as $field) {
            $result = $field->validate();

            if ($result->isFailure()) {
                $errors[] = $result;
            }
        }

        if ($errors) {
            $this->setErrors($errors);

            return false;
        }

        return true;
    }
1371385
protected function validateData()
    {
        $field = 'data';

        if ($this->isExcluded($field)) {
            return null;
        }

        $value = $this->getSubmitted($field);

        if (!isset($value)) {
            $this->unsetSubmitted($field);
            return null;
        }

        if (!is_array($value)) {
            $this->setErrorInvalid($field, $this->translation->text('Data'));
            return false;
        }

        return true;
    }
444039
protected function validateEditPage()
    {
        $this->setSubmitted('page', null, false);
        $this->setSubmitted('form', true);
        $this->setSubmitted('update', $this->data_page);
        $this->setSubmittedBool('status');
        $this->setSubmittedBool('blog_post');

        if (empty($this->data_page['page_id'])) {
            $this->setSubmitted('user_id', $this->uid);
        }

        $this->validateComponent('page');

        return !$this->hasErrors();
    }
129772
public function doValidate()
    {
        $isValid = true;
        if ($this->props['validate']) {
            $isValid = \call_user_func($this->props['validate'], $this);
        }
        return $isValid;
    }
1294567
public function isValid()
    {
        $valid = true;
        foreach ($this->_errors as $input => $message) {
            foreach ($message as $item) {
                if (!empty($item)) {
                    $valid = false;
                }
            }
        }

        foreach ($this->_input as $key => $value) {
            \Session::delete('input.'.$key);
        }

        return $valid;
    }
766251
public function validateForm()
    {
        $validator = $this->getValidationFactory()->make(
            $this->requestData(),
            $this->rules()
        );

        if ($validator->fails())
            throw new \Exception($this->formatErrors($validator->errors()));
    }