Handles validation of user input on API key entry form.

@since  1.0.0

@return string The user's validate API key hash.
327809
protected function validate() {
		$msg = $this->getMessages();

		// Validate nonce.
		if ( ! isset( $_POST['set_key_auth'] ) || ! check_ajax_referer( 'boldgrid_set_key', 'set_key_auth', false ) ) {
			wp_send_json_error( array( 'message' => $msg->nonce ) );
		}

		// Validate user input.
		if ( empty( $_POST['api_key'] ) ) {
			wp_send_json_error( array( 'message' => $msg->error ) );
		}

		// Validate key.
		$valid = new Library\Key\Validate( sanitize_text_field( $_POST['api_key'] ) );
		if ( ! $valid->getValid() ) {
			wp_send_json_error( array( 'message' => $msg->error ) );
		}

		return $valid->getHash();
	}
1051908
public function validateAction()
    {
        // Check for a valid POST request
        if (!$this->getRequest()->isPost()) {
            // Return a "405 Method Not Allowed" response
            $this->getResponse()->setHttpResponseCode(405);
            return;
        }

        $data = $this->getRequest()->getPost();

        // Check that all of the required fields are present
        if (empty($data) || !isset($data['country_id'], $data['region_id'], $data['street'], $data['city'], $data['postcode'])) {
            // Return a "400 Bad Request" response
            $this->getResponse()->setHttpResponseCode(400);
            return;
        }

        $country = Mage::getModel('directory/country')->load($data['country_id'])->getName();
        $region = Mage::getModel('directory/region')->load($data['region_id'])->getCode();

        $result = Mage::helper('australia/address')->validate(
            $data['street'],
            $region,
            $data['city'],
            $data['postcode'],
            $country
        );

        $this->getResponse()->setHeader('Content-type', 'application/json');
        $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
    }
739015
public function postSignin()
    {
        $isEmail = preg_match('/@/', Input::get('email'));

        // Declare the rules for the form validation
        $rules = array(
            'email' => 'required|email',
            'password' => 'required|between:3,32',
        );

        if (!$isEmail)
            $rules['email'] = 'required';

        // Create a new validator instance from our validation rules
        $validator = Validator::make(Input::all(), $rules);

        // If validation fails, we'll exit the operation now.
        if ($validator->fails()) {
            // Ooops.. something went wrong
            return back()->withInput()->withErrors($validator);
        }
        try {
            foreach(Sentinel::createModel()->getLoginNames() as $loginName)
            {
                $data = array(
                    $loginName => Input::only('email')["email"],
                    "password" => Input::only('password')["password"]
                );

                // Try to log the user in
                if(Sentinel::authenticate($data, Input::get('remember-me', false)))
                {
                    $user = Sentinel::check();
                    $user->update(['ip' => Request::ip()]);
                    Base::Log($user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') logged in with IP ' . Request::ip() );
                    
                    // Redirect to the dashboard page
                    return Redirect::route("home")->with('success', Lang::get('base.auth.signin.success'));
                }
            }

            $this->messageBag->add('email', Lang::get('base.auth.account.not_found'));
        } catch (NotActivatedException $e) {
            $this->messageBag->add('email', Lang::get('base.auth.account.not_activated'));
        } catch (ThrottlingException $e) {
            $delay = $e->getDelay();
            $this->messageBag->add('email', Lang::get('base.auth.account.suspended', compact('delay' )));
        }
        Base::Log('Login attempt registred for ' . Input::only('email')["email"] . ' from IP ' . Request::ip() );

        // Ooops.. something went wrong
        return back()->withInput()->withErrors($this->messageBag);
    }
348968
protected function validateUserPasswordInstall()
    {
        $field = 'user.password';

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

        $value = $this->getSubmitted($field);
        $label = $this->translation->text('Password');

        if (empty($value)) {
            $this->setErrorRequired($field, $label);
            return false;
        }

        list($min, $max) = $this->user->getPasswordLength();

        $length = mb_strlen($value);

        if ($length < $min || $length > $max) {
            $this->setErrorLengthRange($field, $label, $min, $max);
            return false;
        }

        return true;
    }
967644
public function validate()
    {
        $value = $this->getValue();
        // Check if the element is required
        if (($this->required) && empty($value)) {
            $this->errors[] = 'This field is required.';
        }
        // Check field validators
        if (count($this->validators) > 0) {
            foreach ($this->validators as $validator) {
                if ($validator instanceof \Pop\Validator\ValidatorInterface) {
                    if (!$validator->evaluate($value)) {
                        if (!in_array($validator->getMessage(), $this->errors)) {
                            $this->errors[] = $validator->getMessage();
                        }
                    }
                } else if (is_callable($validator)) {
                    $result = call_user_func_array($validator, [$value]);
                    if (null !== $result) {
                        if (!in_array($result, $this->errors)) {
                            $this->errors[] = $result;
                        }
                    }
                }
            }
        }
        return (count($this->errors) == 0);
    }
998162
protected function validate() {
        $validator=parent::validate();
        
        //Verify we have a KapostRefID
        $kapostID=$this->KapostRefID;
        if(empty($kapostID)) {
            $validator->error(_t('KapostObject.MISSING_KAPOST_ID', '_Kapost Reference ID is missing'), 'missing-kapost-id');
        }
        
        return $validator;
    }
53917
public function isValid()
	{
	  	// Skip without submission
		if (strtoupper($_SERVER['REQUEST_METHOD']) !== 'POST') {

			return FALSE;

		} else {

			$captchaChallenge = isset($_POST['recaptcha_challenge_field'])
				? $this->_sanitizeField($_POST['recaptcha_challenge_field'])
				: NULL;

			$captchaResponse  = isset($_POST['recaptcha_response_field'])
				? $this->_sanitizeField($_POST['recaptcha_response_field'])
				: NULL;
		 	// Skip empty submission
			if ( strlen($captchaChallenge) == 0 || strlen($captchaResponse) == 0 ) {
				$this->setError('incorrect-captcha-sol');
				return FALSE;
			}

			$data = array(
				'privatekey' => $this->_privateKey,
				'remoteip'   => $this->_remoteIp(),
				'challenge'  => $captchaChallenge,
				'response'   => $captchaResponse
				);

			$result = $this->_postHttpChallenge($data);

			if ( $result['isvalid'] === "true") {
				return TRUE;

			} else {
				$this->setError($result['error']);
			}
			return FALSE;
		}
	}
638217
protected function _validate()
	{

		// Check if validation is necessary and parsed
		if (static::$validates === false) return true;
		if (is_null(static::$_validation)) {
			require_once("Validation/Validation.php");
			static::$_validation = Validation\Validation::onModel(get_called_class());
		}

		
		// Go validate!
		$result = static::$_validation->validate($this);

		// Success?
		if ($result->success == false) {

			// Store errors
			$this->_errors = $result->errors;

			return false;
		} else {

			// Clear errors
			$this->_errors = null;

		}

		// True
		return true;

	}
163610
public function validate() {

		$parent = $this->getParent();

		// The URL segment will conflict with a year/month/day/media format when numeric.

		if(is_numeric($this->URLSegment) || !($parent instanceof MediaHolder) || ($this->MediaTypeID && ($parent->MediaTypeID != $this->MediaTypeID))) {

			// Customise a validation error message.

			if(is_numeric($this->URLSegment)) {
				$message = '"URL Segment" must not be numeric!';
			}
			else if(!($parent instanceof MediaHolder)) {
				$message = 'The parent needs to be a published media holder!';
			}
			else {
				$message = "The media holder type doesn't match this!";
			}
			$error = new HTTPResponse_Exception($message, 403);
			$error->getResponse()->addHeader('X-Status', rawurlencode($message));

			// Allow extension customisation.

			$this->extend('validateMediaPage', $error);
			throw $error;
		}
		return parent::validate();
	}
1181224
protected function validatePasswordLengthUser()
    {
        $field = 'password';

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

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

        if ($this->isUpdating() && (!isset($value) || $value === '')) {
            return null;
        }

        $length = mb_strlen($value);
        list($min, $max) = $this->user->getPasswordLength();

        if ($length < $min || $length > $max) {
            $this->setErrorLengthRange($field, $this->translation->text('Password'), $min, $max);
            return false;
        }

        return true;
    }
151460
public function actionValidate()
    {
        if (\Yii::$app->request->isAjax && !\Yii::$app->request->isPjax) {
            if (\Yii::$app->request->post('sx-model') && \Yii::$app->request->post('sx-model-value')) {
                $modelClass = \Yii::$app->request->post('sx-model');
                $modelValue = \Yii::$app->request->post('sx-model-value');

                /**
                 * @var $modelForm Form
                 */
                $modelForm = $modelClass::find()->where(['id' => $modelValue])->one();

                if (method_exists($modelForm, "createPropertiesValidateModel")) {
                    $model = $modelForm->createPropertiesValidateModel();
                } else {
                    $model = $modelForm->getRelatedPropertiesModel();
                }

                $model->load(\Yii::$app->request->post());

                \Yii::$app->response->format = Response::FORMAT_JSON;
                return ActiveForm::validate($model);
            }
        }
    }
445459
protected function getInputData ()
    {
        (new HCAppsTokensValidator())->validateForm ();

        $_data = request ()->all ();

        $token = array_get ($_data, 'token');

        if (strlen($token) != 255)
            $token = random_str(255);

        array_set ($data, 'record.expires_at', array_get ($_data, 'expires_at'));
        array_set ($data, 'record.token', $token);
        array_set ($data, 'record.app_id', array_get ($_data, 'app_id'));

        return $data;
    }
1289978
public function validate()
    {
        if (($_FILES) && (isset($_FILES[$this->name]['name']))) {
            $value = $_FILES[$this->name]['name'];
            $size  = $_FILES[$this->name]['size'];
        } else {
            $value = null;
            $size  = null;
        }
        // Check if the element is required
        if (($this->required) && empty($value)) {
            $this->errors[] = 'This field is required.';
        }
        // Check field validators
        if (count($this->validators) > 0) {
            foreach ($this->validators as $validator) {
                if ($validator instanceof \Pop\Validator\ValidatorInterface) {
                    $class =  get_class($validator);
                    if ((null !== $size) &&
                        (('Pop\Validator\LessThanEqual' == $class) || ('Pop\Validator\GreaterThanEqual' == $class) ||
                         ('Pop\Validator\LessThan' == $class) || ('Pop\Validator\GreaterThan' == $class))) {
                        if (!$validator->evaluate($size)) {
                            $this->errors[] = $validator->getMessage();
                        }
                    } else {
                        if (!$validator->evaluate($value)) {
                            $this->errors[] = $validator->getMessage();
                        }
                    }
                } else if (is_callable($validator)) {
                    $result = call_user_func_array($validator, [$value]);
                    if (null !== $result) {
                        $this->errors[] = $result;
                    }
                }
            }
        }
        return (count($this->errors) == 0);
    }
645686
public function validateInput(): bool
    {
        if (!$def = $this->definition) {
            return true;
        }

        $in        = $this->input;
        $out       = $this->output;
        $givenArgs = $errArgs = [];

        foreach ($in->getArgs() as $key => $value) {
            if (\is_int($key)) {
                $givenArgs[$key] = $value;
            } else {
                $errArgs[] = $key;
            }
        }

        if (\count($errArgs) > 0) {
            $out->liteError(\sprintf('Unknown arguments (error: "%s").', \implode(', ', $errArgs)));
            return false;
        }

        $defArgs     = $def->getArguments();
        $missingArgs = \array_filter(\array_keys($defArgs), function ($name, $key) use ($def, $givenArgs) {
            return !\array_key_exists($key, $givenArgs) && $def->argumentIsRequired($name);
        }, \ARRAY_FILTER_USE_BOTH);

        if (\count($missingArgs) > 0) {
            $out->liteError(\sprintf('Not enough arguments (missing: "%s").', \implode(', ', $missingArgs)));
            return false;
        }

        $index = 0;
        $args  = [];

        foreach ($defArgs as $name => $conf) {
            $args[$name] = $givenArgs[$index] ?? $conf['default'];
            $index++;
        }

        $in->setArgs($args);

        // check options
        $opts      = $missingOpts = [];
        $givenOpts = $in->getOptions();
        $defOpts   = $def->getOptions();

        // check unknown options
        if ($unknown = \array_diff_key($givenOpts, $defOpts)) {
            $names = \array_keys($unknown);
            $first = \array_shift($names);

            throw new \InvalidArgumentException(\sprintf(
                'Input option is not exists (unknown: "%s").',
                (isset($first[1]) ? '--' : '-') . $first
            ));
        }

        foreach ($defOpts as $name => $conf) {
            if (!$in->hasLOpt($name)) {
                if (($srt = $conf['shortcut']) && $in->hasSOpt($srt)) {
                    $opts[$name] = $in->sOpt($srt);
                } elseif ($conf['required']) {
                    $missingOpts[] = "--{$name}" . ($srt ? "|-{$srt}" : '');
                }
            }
        }

        if (\count($missingOpts) > 0) {
            $out->liteError(
                \sprintf('Not enough options parameters (missing: "%s").',
                    \implode(', ', $missingOpts))
            );
            return false;
        }

        if ($opts) {
            $in->setLOpts($opts);
        }

        return true;
    }
554172
public function validate() : void
    {
        if (null === $this->is_valid) {
            if (null === $this->user_value && null !== $this->default_value) {
                // There is a preset value, and its not being changed
                $this->is_valid = true;
            } elseif (in_array($this->user_value, array_keys($this->options)) && !in_array($this->user_value,
                    $this->disabled)
            ) {
                $this->is_valid = true;
            } elseif ('' == $this->user_value && $this->addBlank && !in_array('', $this->disabled)) {
                $this->is_valid = true;
            } elseif (false == $this->validator) {
                // This field does not get validated
                $this->is_valid = true;
            } else {
                $this->is_valid = false;
                $this->error = 'The provided value is not valid. Please enter a valid value.';
            }
        }

        // Check if the input is different from the default value
        if ($this->is_valid && null !== $this->user_value) {
            $this->is_changed = ($this->default_value != $this->user_value);
        }
    }
458513
function validateInput( $http, $base,
                            &$inputParameters, $validationParameters = array() )
    {
        $dataType = $this->dataType();
        if ( $dataType )
        {
            $this->setInputParameters( $inputParameters );
            $this->setValidationParameters( $validationParameters );
            $this->IsValid = $dataType->validateObjectAttributeHTTPInput( $http, $base, $this );
            $this->unsetValidationParameters();
            $this->unsetInputParameters();
        }
        return $this->IsValid;
    }
325862
public function ValidateUserInput()
    {
        $bIsValid = parent::ValidateUserInput();
        $oMsgManager = TCMSMessageManager::GetInstance();
        $aRequiredFields = array('accountNr', 'accountOwner', 'bankNr', 'bankName');
        foreach ($aRequiredFields as $sRequiredField) {
            $sValue = (array_key_exists($sRequiredField, $this->aPaymentUserData)) ? ($this->aPaymentUserData[$sRequiredField]) : ('');
            $sValue = trim($sValue);
            if (empty($sValue)) {
                $oMsgManager->AddMessage(self::MSG_MANAGER_NAME.'-'.$sRequiredField, 'ERROR-USER-REQUIRED-FIELD-MISSING');
                $bIsValid = false;
            }
        }

        return $bIsValid;
    }