Validates product categories
@return boolean
323794
protected function validateCategoryProduct()
    {
        $fields = array(
            'category_id' => $this->translation->text('Category'),
            'brand_category_id' => $this->translation->text('Brand'),
        );

        $errors = 0;

        foreach ($fields as $field => $label) {

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

            if (!isset($value)) {
                continue;
            }

            if (!is_numeric($value)) {
                $errors++;
                $this->setErrorNumeric($field, $label);
                continue;
            }

            if (empty($value)) {
                continue;
            }

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

            if (empty($category['category_id'])) {
                $errors++;
                $this->setErrorUnavailable($field, $label);
            }
        }

        return empty($errors);
    }
514708
public function valid()
    {
        $isValid = $this->isFlagSet(self::STATUS_VALID);
        $subscriptionFlags = self::STATUS_SUBSCRIBED | self::STATUS_PSUBSCRIBED;
        $hasSubscriptions = ($this->statusFlags & $subscriptionFlags) > 0;

        return $isValid && $hasSubscriptions;
    }
327055
protected function validate()
    {
        $valid = parent::validate();
        foreach ($this as $child) {
            $valid = $child->validate() && $valid;
        }
        return $valid;
    }
186318
protected function validateCart()
    {
        $id = $this->getUpdatingId();

        if ($id === false) {
            return null;
        }

        $data = $this->cart->get($id);

        if (empty($data)) {
            $this->setErrorUnavailable('update', $this->translation->text('Cart'));
            return false;
        }

        $this->setUpdating($data);
        return true;
    }
48761
protected function validateAttributeProduct()
    {
        $fields = $this->getSubmitted('product_fields.attribute');

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

        $attributes = $this->getSubmitted('field.attribute');

        $errors = 0;

        foreach ($fields as $field_id => $field) {
            if (!empty($field['required']) && empty($attributes[$field_id])) {
                $this->setErrorRequired("attribute.$field_id", $field['title']);
                $errors++;
            }
        }

        return empty($errors);
    }
728743
def validate_categories(categories):
        """"""
        if not set(categories) <= Source.categories:
            invalid = list(set(categories) - Source.categories)
            raise ValueError('Invalid categories: %s' % invalid)
254242
public function dontShowEmptyCategories()
    {
        if ($this->_blDontShowEmptyCats == null) {
            $this->_blDontShowEmptyCats = false;
            if ($dontShowEmptyCats = \OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('blDontShowEmptyCategories')) {
                $this->_blDontShowEmptyCats = $dontShowEmptyCats;
            }
        }

        return $this->_blDontShowEmptyCats;
    }
387301
protected function validateProductClassProductClassField()
    {
        $field = 'product_class_id';

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

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

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

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

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

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

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

        if (empty($product_class)) {
            $this->setErrorUnavailable('update', $label);
            return false;
        }

        return true;
    }
821354
protected function performValidation()
    {
        // All the fixed fields declared above are objects that MUST use keys that match the regular expression: ^[a-zA-Z0-9\.\-_]+$.
        foreach (array_keys($this->attributes()) as $attribute) {
            if (is_array($this->$attribute)) {
                foreach ($this->$attribute as $k => $v) {
                    if (!preg_match('~^[a-zA-Z0-9\.\-_]+$~', $k)) {
                        $this->addError("Invalid key '$k' used in Components Object for attribute '$attribute', does not match ^[a-zA-Z0-9\.\-_]+\$.");
                    }
                }
            }
        }
    }
781588
protected function validateProductClassField()
    {
        $id = $this->getUpdatingId();

        if ($id === false) {
            return null;
        }

        $data = $this->product_class_field->get($id);

        if (empty($data)) {
            $this->setErrorUnavailable('update', $this->translation->text('Address'));
            return false;
        }

        $this->setUpdating($data);
        return true;
    }
186852
protected function validateEditProductBundle()
    {
        $this->setSubmitted('product');
        $this->setSubmitted('product_id', $this->data_product['product_id']);

        $this->validateComponent('product_bundle');

        return !$this->hasErrors();
    }
491715
protected function isInCategories(array $category)
    {
        $url = ltrim(wei()->request->getPathInfo(), '/');
        foreach ($category['navs'] as $i => $subCategories) {
            foreach ($subCategories['navs'] as $nav) {
                if ($nav['url'] == $url) {
                    return true;
                }
            }
        }

        return false;
    }
797382
public function validation()
	{
		if( ! $this->_validation)
		{
			$this->_validation = \Validation::forge(\Str::random('alnum', 32));

			if (isset(static::$_rules) and count(static::$_rules))
			{
				foreach (static::$_rules as $field => $rules)
				{
					$label = (isset(static::$_labels) and array_key_exists($field, static::$_labels)) ? static::$_labels[$field] : $field;
					$this->_validation->add_field($field, $label, $rules);
				}
			}
		}

		return $this->_validation;
	}
335134
final public function validate(): bool
    {
        // validate csrf token if required
        if ($this->_tokenRequired && !$this->_tokenOk) {
            App::$Session->getFlashBag()->add('warning', __('Hack attention: security token is wrong!'));
            return false;
        }
        // get all rules as array from method rules()
        $rules = $this->rules();
        // get default values of attributes
        $defaultAttr = $this->getAllProperties();

        // start validation: on this step class attribute values will be changed to input data if it valid
        $success = $this->runValidate($rules);

        // get not-passed validation fields as array
        $badAttributes = $this->getBadAttributes();
        // prevent warnings
        if (Any::isArray($badAttributes) && count($badAttributes) > 0) {
            foreach ($badAttributes as $attr) {
                if (Str::contains('.', $attr)) { // sounds like dot-separated array attr
                    $attrName = strstr($attr, '.', true); // get attr name
                    $attrArray = trim(strstr($attr, '.'), '.'); // get dot-based array path

                    $defaultValue = new DotData($defaultAttr); // load default attr

                    $dotData = new DotData($this->{$attrName}); // load local attr variable
                    $dotData->set($attrArray, $defaultValue->get($attr)); // set to local prop. variable default value

                    $this->{$attrName} = $dotData->export(); // export to model
                } else {
                    $this->{$attr} = $defaultAttr[$attr]; // just set ;)
                }
                // add message about wrong attribute to session holder, later display it
                $attrLabel = $attr;
                if ($this->getLabel($attr) !== null) {
                    $attrLabel = $this->getLabel($attr);
                }

                App::$Session->getFlashBag()->add('warning', __('Field "%field%" is incorrect', ['field' => $attrLabel]));
            }
        }

        return $success;
    }
1072280
protected function validateDimensionProduct()
    {
        $fields = array(
            'width' => $this->translation->text('Width'),
            'height' => $this->translation->text('Height'),
            'length' => $this->translation->text('Length'),
            'weight' => $this->translation->text('Weight')
        );

        $errors = 0;
        foreach ($fields as $field => $label) {

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

            if (!isset($value)) {
                continue;
            }

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

            if (strlen($value) > 10) {
                $errors++;
                $this->setErrorLengthRange($field, $label, 0, 10);
            }
        }

        return empty($errors);
    }
32622
protected function validateGaProfileSettings()
    {
        $profiles = $this->getSubmitted('ga_profile_id', array());

        if (empty($profiles)) {
            $this->setError('ga_profile_id', $this->text('Profile ID is required'));
            return false;
        }

        $stores = $this->store->getList();

        foreach ($profiles as $store_id => $profile_id) {

            if (empty($profile_id)) {
                $this->setError('ga_profile_id', $this->text('Profile ID is required'));
                return false;
            }

            if (empty($stores[$store_id])) {
                $this->setError('ga_profile_id', $this->text('Unknown store ID'));
                return false;
            }
        }

        return true;
    }
271725
public function validate(): bool
    {
        if (! $this->requestIsValid()) {
            return false;
        }

        $requestOptions = $this->getDefaultRequestOptions();
        $customOptions = $this->getCustomRequestOptions();

        if (! empty($customOptions) && is_array($customOptions)) {
            $requestOptions = array_merge($requestOptions, $customOptions);
        }

        $response = $this->guzzleClient->request('POST', self::OPENID_URL, $requestOptions);

        $results = $this->parseResults($response->getBody()->getContents());

        $this->parseSteamID();
        $this->parseInfo();

        return $results->is_valid == 'true';
    }