Validates an array of submitted data before creating an order
@return array
481358
protected function validateOrderCheckout()
    {
        if ($this->same_payment_address) {
            $this->unsetSubmitted('address.payment');
        }

        $this->setSubmitted('update', array());
        $this->setSubmitted('store_id', $this->store_id);
        $this->setSubmitted('user_id', $this->order_user_id);
        $this->setSubmitted('creator', $this->admin_user_id);

        if ($this->admin) {
            $this->setSubmitted('status', $this->order->getStatusInitial());
        }

        return $this->validateComponent('order');
    }
1210221
public function validate(array $data = []) : array
    {
        $validated = false;
        $errors = [];

        if (empty($this->requiredFields)) {
            $errors[] = "Missing requiredFields in the report object";
        }

        foreach ($this->requiredFields as $field) {
            if (!isset($data['info'][$field])) {
                $errors[] = "Required field [$field] must be set";
            }

            if (empty($data['info'][$field])) {
                $errors[] = "Required Field [$field] cannot be empty";
            }
        }

        if (empty($errors)) {
            $validated = true;
            $this->errors = [];
        } else {
            $this->errors = $errors;
        }

        return ['status' => $validated, 'messages' => $errors];
    }
261527
protected function validatePaymentAddressOrder()
    {
        $field = 'payment_address';

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

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

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

        if (empty($value) && !$this->isError('shipping_address')) {
            $value = $this->getSubmitted('shipping_address');
        }

        $label = $this->translation->text('Payment address');

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

        if (!is_numeric($value)) {
            $this->setErrorNumeric($field, $label);
            return false;
        }

        $address = $this->address->get($value);

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

        $this->setSubmitted($field, $value);
        return true;
    }
550515
public function getValidAttribs()
    {
        return array_combine(
            array_keys($this->validAttribs),
            array_map(function ($ref) {
                return $ref['attrib'];
            }, array_values($this->validAttribs))
        );
    }
699528
function _isArrayValidate (type) {
  return (value) => {
    if (!Array.isArray(value)) {
      throw new Error(`Debe ser un Array.`)
    }
    value.forEach(val => {
      if ((type.key === 'STRING') && !Sequelize.Validator.len(`${val}`, 0, type.options.length)) {
        throw new Error(`Cada elemento debe ser una cadena de texto con un máximo de ${type.options.length} caracteres.`)
      }
      if ((type.key === 'TEXT') && !Sequelize.Validator.len(`${val}`, 0, 2147483647)) {
        throw new Error(`Cada elemento debe ser una cadena de texto.`)
      }
      if ((type.key === 'INTEGER') && !Sequelize.Validator.isInt(`${val}`)) {
        throw new Error(`Cada elemento debe ser de un número de tipo INTEGER.`)
      }
      if ((type.key === 'FLOAT') && !Sequelize.Validator.isFloat(`${val}`)) {
        throw new Error(`Cada elemento debe ser de un número de tipo FLOAT.`)
      }
      if ((type.key === 'BOOLEAN') && !Sequelize.Validator.isBoolean(`${val}`)) {
        throw new Error(`Cada elemento debe ser de tipo boolean.`)
      }
      if ((type.key === 'DATE') && !Sequelize.Validator.isDate(`${val}`)) {
        throw new Error(`Cada elemento debe ser una fecha válida.`)
      }
      if ((type.key === 'DATEONLY') && !Sequelize.Validator.isDate(`${val}`)) {
        throw new Error(`Cada elemento debe ser una fecha válida.`)
      }
      if ((type.key === 'TIME') && !moment(val, 'HH:mm:ss', true).isValid()) {
        throw new Error(`Cada elemento debe ser una hora válida.`)
      }
      if ((type.key === 'JSON') && (typeof val !== 'object')) {
        throw new Error(`Cada elemento debe ser un objeto de tipo JSON.`)
      }
      if ((type.key === 'JSONB') && (typeof val !== 'object')) {
        throw new Error(`Cada elemento debe ser un objeto de tipo JSON.`)
      }
      if ((type.key === 'UUID') && !Sequelize.Validator.isUUID(`${val}`)) {
        throw new Error(`Cada elemento debe ser una cadena de texto de tipo UUID.`)
      }
      if ((type.key === 'ENUM') && !Sequelize.Validator.isIn(`${val}`, type.values)) {
        throw new Error(`Cada elemento debe ser uno de los siguientes valores: ${type.values.toString()}.`)
      }
    })
  }
}
1223373
private function checkValidity()
    {

        if (!is_writable($this->rssFile)) {
            $this->valid = false;
            return;
        }

        $stmt = $this->db->prepare('SELECT CREATED FROM ' . $this->table . ' ORDER BY CREATED DESC LIMIT 1');
        $stmt->execute();
        $res = $stmt->fetchAll();

        if (count($res) == 0) {
            $this->valid = false;
            return;
        }

        $latestInput = strtotime($res[0]->CREATED);

        $rssCreated = filemtime($this->rssFile);

        if ($latestInput > $rssCreated) {
            $this->valid = false;
        } else {
            $this->valid = true;
        }
    }
34715
protected function getSubmittedOrderCheckout()
    {
        $submitted = $this->getSubmitted();
        $submitted += $this->data_form['order'];
        $submitted['cart'] = $this->data_cart;

        $submitted['data']['user'] = array(
            'ip' => $this->server->remoteAddr(),
            'agent' => $this->server->userAgent()
        );

        if (empty($this->admin)) {
            return $submitted;
        }

        // Convert decimal prices from inputs in admin mode
        $submitted['total'] = $this->price->amount($submitted['total'], $submitted['currency']);

        if (empty($submitted['data']['components'])) {
            return $submitted;
        }

        $this->prepareSubmittedOrderComponentsCheckout($submitted);
        return $submitted;
    }
413377
protected function validateStatusOrder()
    {
        $field = 'status';
        $value = $this->getSubmitted($field);

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

        $statuses = $this->order->getStatuses();

        if (empty($statuses[$value])) {
            $this->setErrorUnavailable($field, $this->translation->text('Status'));
            return false;
        }

        return true;
    }
308720
public function validate(array $data)
    {
        $errors = [];

        if (empty($data['name'])) {
            $errors[] = ['path' => '/name', 'message' => 'name can not be empty.'];
        }

        if (empty($data['type'])) {
            $errors[] = ['path' => '/type', 'message' => 'type can not be empty.'];
        }

        if (empty($data['scheduledDate'])) {
            $errors[] = ['path' => '/scheduledDate', 'message' => 'scheduledDate can not be empty.'];
        }

        return $errors;
    }
544152
protected function beforeValidate() 
	{
		if(parent::beforeValidate()) {
			if($this->isNewRecord) {
				if($this->actived == 1)
					$this->orders = count(self::getPlugin(1, null, 'data')) + 1;
				else
					$this->orders = 0;
				
				$this->creation_id = !Yii::app()->user->isGuest ? Yii::app()->user->id : null;
			} else
				$this->modified_id = !Yii::app()->user->isGuest ? Yii::app()->user->id : null;
		}
		return true;
	}
1080705
public function validated(): array
    {
        $config = $this->container->make('katsana.manager')->config('webhook');

        $signature = new Signature($config['signature']);
        $header = $this->header('X_SIGNATURE') ?? '';

        if (! $signature->verify($header, $this->getContent(), ($config['threshold'] ?? 3600))) {
            throw new HttpException(419, 'Unable to verify X-Signature.');
        }

        return $this->post();
    }
44890
public function validate()
    {
        $result = parent::validate();
        $checkEmail = [
            'EmailAddress' => 'EMAILADDRESSINVALID',
            'EmailFrom' => 'EMAILFROMINVALID',
            'EmailReplyTo' => 'EMAILREPLYTOINVALID',
        ];
        foreach ($checkEmail as $check => $translation) {
            if ($this->$check) {
                //may be a comma separated list of emails
                $addresses = explode(',', $this->$check);
                foreach ($addresses as $address) {
                    $trimAddress = trim($address);
                    if ($trimAddress && !Email::is_valid_address($trimAddress)) {
                        $error = _t(
                            __CLASS__.".$translation",
                            "Invalid email address $trimAddress"
                        );
                        $result->addError($error . " ($trimAddress)");
                    }
                }
            }
        }

        // if there is no from address and no fallback, you'll have errors if this isn't defined
        if (!$this->EmailFrom && empty(Email::getSendAllEmailsFrom()) && empty(Email::config()->get('admin_email'))) {
            $result->addError(_t(__CLASS__.".EMAILFROMREQUIRED", '"Email From" address is required'));
        }
        return $result;
    }
598873
public function validate(?array $data): array
    {
        $errorMsgs = [];
        foreach ($this->fieldsRuleProperties as $fieldName => $ruleProperties) {
            // Get value to validate
            if (isset($data[$fieldName])) {
                $value = $data[$fieldName];

                // Trim all values unless explicitly set to not
                if (is_string($value) && (!isset($ruleProperties['trim']) || $ruleProperties['trim'] === true)) {
                    $value = trim($value);
                }
                // allow a nullable value to be added as validated data
            } elseif (!empty($ruleProperties['nullable']) && array_key_exists($fieldName, $data)) {
                $value = null;
                // Don't validate empty values that are not set and not required
            } elseif (empty($ruleProperties['required']) && empty($ruleProperties['nonEmpty'])) {
                continue;
            } else {
                // Empty string as default (not null because that adds complexity to checks)
                $value = '';
            }

            // Validate value against each of the fields' rules
            $errorMsg = $this->validateValue($value, $ruleProperties);

            // If field has any error messages, add to error array, otherwise add value to validated data
            if ($errorMsg) {
                $errorMsgs[$fieldName] = $errorMsg;
            } else {
                $this->validatedData[$fieldName] = $value;
            }
        }

        return $errorMsgs;
    }
687674
protected function beforeValidate() 
	{
		$controller = strtolower(Yii::app()->controller->id);
		$setting = BannerSetting::model()->findByPk(1, array(
			'select' => 'banner_validation, banner_file_type',
		));
		$banner_file_type = unserialize($setting->banner_file_type);
		if(empty($banner_file_type))
			$banner_file_type = array();
		
		if(parent::beforeValidate()) {
			if($this->isNewRecord)
				$this->creation_id = !Yii::app()->user->isGuest ? Yii::app()->user->id : null;
			else
				$this->modified_id = !Yii::app()->user->isGuest ? Yii::app()->user->id : null;
			
			$banner_filename = CUploadedFile::getInstance($this, 'banner_filename');
			if($banner_filename != null) {
				$extension = pathinfo($banner_filename->name, PATHINFO_EXTENSION);
				$validation = 0;
				if($setting->banner_validation == 1)
					$validation = 1;
				$fileSize = getimagesize($banner_filename->tempName);
				$bannerSize = unserialize($this->category->banner_size);
				
				if(!in_array(strtolower($extension), $banner_file_type))
					$this->addError('banner_filename', Yii::t('phrase', 'The file {name} cannot be uploaded. Only files with these extensions are allowed: {extensions}.', array(
						'{name}'=>$banner_filename->name,
						'{extensions}'=>Utility::formatFileType($banner_file_type, false),
					)));
				else {
					if($validation == 1 && !($fileSize[0] == $bannerSize['width'] && $fileSize[1] == $bannerSize['height']))
						$this->addError('banner_filename', Yii::t('phrase', 'The file {name} cannot be uploaded. ukuran banner ({file_size}) tidak sesuai dengan kategori ({banner_size})', array(
							'{name}'=>$banner_filename->name,
							'{file_size}'=>$fileSize[0].' x '.$fileSize[1],
							'{banner_size}'=>$bannerSize['width'].' x '.$bannerSize['height'],
						)));
				}
			} else {
				if($this->isNewRecord && $controller == 'o/admin')
					$this->addError('banner_filename', Yii::t('phrase', 'Banner (File) cannot be blank.'));
			}
			
			if($this->linked_i == 0)
				$this->url = '-';
			
			if(in_array(Yii::$app->formatter->asDate($this->expired_date, 'php:Y-m-d'), array('00-00-0000','01-01-1970')))
				$this->permanent_i = 1;
			
			if($this->permanent_i == 1)
				$this->expired_date = '00-00-0000';
			
			if($this->linked_i == 1 && $this->url == '-')
				$this->addError('url', Yii::t('phrase', 'URL harus dalam format hyperlink'));
			
			if($this->permanent_i != 1 && ($this->published_date != '' && $this->expired_date != '') && ($this->published_date >= $this->expired_date))
				$this->addError('expired_date', Yii::t('phrase', 'Expired lebih kecil'));
		}
		return true;
	}
654834
public function validateValidItem()
    {
        if (!$this->value) {
            return;
        }

        // load allowed values in values_list
        // @todo Imants: Actually we don't need to load all values from Model in
        //       array, just to check couple of posted values.
        //       Probably we should do SELECT * FROM t WHERE id IN ($values) or
        //       something like that to limit array size and time spent on
        //       parsing all DB records in Model.
        $this->getValueList();

        $values = explode($this->separator, $this->value);
        foreach ($values as $v) {
            if (!isset($this->value_list[$v])) {
                $this->displayFieldError("Value $v is not one of the offered values");

                return $this->validate();
            }
        }
    }
373019
public function validate_input( $post_array = null ) {
		! isset( $post_array ) and $post_array = $this->app->input->post();
		$errors = [];
		foreach ( $this->get_data_field_settings() as $k => $v ) {
			$param    = $this->get_post_field( $k, null, $post_array, $v );
			$param    = $this->sanitize_input( $param, $v['type'] );
			$validate = $this->validate( $param, $v );
			if ( $validate instanceof \WP_Error ) {
				$errors[ $k ][] = $validate->get_error_message();
			}
		}

		if ( $this->validate_post_title() && in_array( 'title', $this->get_post_type_supports() ) ) {
			if ( ! isset( $post_array['post_title'] ) || '' === trim( $post_array['post_title'] ) ) {
				$errors['post_title'][] = $this->app->translate( 'Value is required.' );
			}
		}

		return $this->filter_validate_input( $errors, $post_array );
	}
1055576
protected function validateCreatorOrder()
    {
        $field = 'creator';
        $value = $this->getSubmitted($field);

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

        if (empty($value)) {
            return null;
        }

        $label = $this->translation->text('Creator');

        if (!is_numeric($value)) {
            $this->setErrorNumeric($field, $label);
            return false;
        }

        $user = $this->user->get($value);

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

        return true;
    }