Prepare the data for validation.

@return void
345948
protected function prepareForValidation(): void
    {
        $data = $this->all();

        // Calculate price
        $endsAt = new Carbon($data['ends_at']);
        $startsAt = new Carbon($data['starts_at']);
        $service = app('cortex.bookings.service')->find($data['service_id']);
        [$price, $formula, $currency] = app('cortex.bookings.service_booking')->calculatePrice($service, $startsAt, $endsAt, $data['quantity']);

        // Fill missing fields
        $data['ends_at'] = $endsAt;
        $data['starts_at'] = $startsAt;
        $data['customer_type'] = 'member';
        $data['bookable_type'] = 'service';
        $data['currency'] = $currency;
        $data['formula'] = $formula;
        $data['price'] = $price;

        $this->replace($data);
    }
69649
public function validate()
	{
		// reset the error container and status
		$this->errors = array();
		$this->isValid = true;

		// validation starts, call the pre-validation callback
		$this->runCallbacks('before_validation');

		// was the upload of the file a success?
		if ($this->container['error'] == 0)
		{
			// add some filename details (pathinfo can't be trusted with utf-8 filenames!)
			$this->container['extension'] = ltrim(strrchr(ltrim($this->container['name'], '.'), '.'),'.');
			if (empty($this->container['extension']))
			{
				$this->container['basename'] = $this->container['name'];
			}
			else
			{
				$this->container['basename'] = substr($this->container['name'], 0, strlen($this->container['name'])-(strlen($this->container['extension'])+1));
			}

			// does this upload exceed the maximum size?
			if ( ! empty($this->config['max_size']) and is_numeric($this->config['max_size']) and $this->container['size'] > $this->config['max_size'])
			{
				$this->addError(static::UPLOAD_ERR_MAX_SIZE);
			}

			// add mimetype information
			try
			{
				$handle = finfo_open(FILEINFO_MIME_TYPE);
				$this->container['mimetype'] = finfo_file($handle, $this->container['tmp_name']);
				finfo_close($handle);
			}
			// this will only work if PHP errors are converted into ErrorException (like when you use FuelPHP)
			catch (\ErrorException $e)
			{
				$this->container['mimetype'] = false;
				$this->addError(UPLOAD_ERR_NO_FILE);
			}

			// make sure it contains something valid
			if (empty($this->container['mimetype']) or strpos($this->container['mimetype'], '/') === false)
			{
				$this->container['mimetype'] = 'application/octet-stream';
			}

			// split the mimetype info so we can run some tests
			preg_match('|^(.*)/(.*)|', $this->container['mimetype'], $mimeinfo);

			// check the file extension black- and whitelists
			if (in_array(strtolower($this->container['extension']), (array) $this->config['ext_blacklist']))
			{
				$this->addError(static::UPLOAD_ERR_EXT_BLACKLISTED);
			}
			elseif ( ! empty($this->config['ext_whitelist']) and ! in_array(strtolower($this->container['extension']), (array) $this->config['ext_whitelist']))
			{
				$this->addError(static::UPLOAD_ERR_EXT_NOT_WHITELISTED);
			}

			// check the file type black- and whitelists
			if (in_array($mimeinfo[1], (array) $this->config['type_blacklist']))
			{
				$this->addError(static::UPLOAD_ERR_TYPE_BLACKLISTED);
			}
			if ( ! empty($this->config['type_whitelist']) and ! in_array($mimeinfo[1], (array) $this->config['type_whitelist']))
			{
				$this->addError(static::UPLOAD_ERR_TYPE_NOT_WHITELISTED);
			}

			// check the file mimetype black- and whitelists
			if (in_array($this->container['mimetype'], (array) $this->config['mime_blacklist']))
			{
				$this->addError(static::UPLOAD_ERR_MIME_BLACKLISTED);
			}
			elseif ( ! empty($this->config['mime_whitelist']) and ! in_array($this->container['mimetype'], (array) $this->config['mime_whitelist']))
			{
				$this->addError(static::UPLOAD_ERR_MIME_NOT_WHITELISTED);
			}

			// validation finished, call the post-validation callback
			$this->runCallbacks('after_validation');
		}
		else
		{
			// upload was already a failure, store the corresponding error
			$this->addError($this->container['error']);
		}

		// set the flag to indicate we ran the validation
		$this->isValidated = true;

		// return the validation state
		return $this->isValid;
	}
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);
        }
    }
463354
public function beforeValidate()
    {
        foreach ($this->attributes as $attribute) {
            $this->owner->$attribute = HtmlPurifier::process($this->owner->$attribute, $this->config);
        }
    }
1294612
public function validate()
    {
        $order = $this->getInfoInstance()->getOrder();

        if ($order) {
            // Force to generate REF from Order ID.
            $this->assignData(null);
        }

        return parent::validate();
    }
87954
protected function prepare()
    {
        // Set data into dataDocument structure;
        if (is_array($this->data)) {
            foreach ($this->data as $key => $value) {
                $this->addData($key, $value);
            }
        }

     Logger::get()->debug("Response data:\n" . $this->dataDocument->toString(false));

        // Merge data with template.
        $this->document = $this->dataDocument->transform($this->getTemplate());
    }
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();
	}
1207372
public function validation()
    {
        $validator = new Validation();

        $validator->add(
            'name',
            new PresenceOf([
                'model' => $this,
                'required' => true,
            ])
        );

        return $this->validate($validator);
    }
417693
public function prepare(){
		if(is_array($this->params['items'])){
			$this->items=array();
			foreach($this->params['items'] as $k=>$v){
				$this->items[$k]=$v;
				}
			}
		}
803308
public function validate() {
		parent::validate();

		if ($this->getId() === null) {
			throw new ValidationException("'id' can't be null", 'id', $this);
		}
		if ($this->getVersion() === null) {
			throw new ValidationException("'version' can't be null", 'version', $this);
		}
	}
359880
public function prepare()
    {
        $this->startedAt = microtime(true);

        if ($this->getOption('debug')) {
            $this->logger->setLevel(LogLevel::DEBUG);
        } elseif ($this->getOption('verbose')) {
            $this->logger->setLevel(LogLevel::INFO);
        } elseif ($this->getOption('quiet')) {
            $this->logger->setLevel(LogLevel::ERROR);
        } elseif ($this->config('debug', false)) {
            $this->logger->setLevel(LogLevel::DEBUG);
        } elseif ($this->config('verbose', false)) {
            $this->logger->setLevel(LogLevel::INFO);
        }

        return true;
    }
1020159
public function validate()
    {
        // Generate validator instance
        $this->validator = $this->validatorFactory->make($this->getData(), $this->getRules(), $this->getMessages(), $this->getAttributes());

        // Validation was a success!
        if (! $this->validator->fails()) {
            return true;
        }

        // Collect validation errors
        $this->errors = $this->validator->messages();

        return false;
    }
238622
protected function prepare()
    {
        if (!is_array($this->data) || count($this->data) == 0) {
            $this->setData($this->read());
        }
    }
1262864
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 (null != $this->validator && false != $this->validator) {
                if ('' === $this->user_value && false === $this->required) {
                    $this->is_valid = true;
                    return;
                } elseif ('' === $this->user_value && true === $this->required) {
                    $this->is_valid = false;
                    return;
                }
                try {
                    $validator = $this->validator;
                    $result = $validator::quickValidate($this->user_value, $this->constraints);
                    $this->user_value = $result;
                    $this->is_valid = true;
                } catch (InvalidInputException $e) {
                    $this->user_value = null;
                    $this->is_valid = false;
                    $this->error = $e->getMessage();
                }

            } else {
                // This field does not get validated
                $this->is_valid = true;
            }
        }
        // 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);
        }
    }
448248
protected function prepareRequest()
    {
        $this->formatUrl();
        $this->validateInput();
        $this->addHeaders();
        $this->addRequestBody();
        $this->initOptions();
    }
85546
public function validate() {
		parent::validate();

		if ($this->getEntity() === null) {
			throw new ValidationException("'entity' can't be null", 'entity', $this);
		}
		if ($this->getEntityStates() === null) {
			throw new ValidationException("'entityStates' can't be null", 'entityStates', $this);
		}
		if ($this->getUrl() === null) {
			throw new ValidationException("'url' can't be null", 'url', $this);
		}
	}
239499
public function validate()
    {
        // If validation is disabled, skip this step
        if (!DataObject::config()->uninherited('validation_enabled')) {
            return ValidationResult::create();
        }

        $valid = parent::validate();
        $validator = static::password_validator();

        if (!$this->ID || $this->isChanged('Password')) {
            if ($this->Password && $validator) {
                $userValid = $validator->validate($this->Password, $this);
                $valid->combineAnd($userValid);
            }
        }

        return $valid;
    }