Validates an array of submitted command data
@param array $submitted
@param array $options
@return mixed
179749
public function validateUpload(array &$submitted, array $options = array())
    {
        $this->options = $options;
        $this->submitted = &$submitted;

        $this->validateLimitsUpload();
        $this->validateFileUpload();

        return $this->getResult();
    }
460499
public function page(array &$submitted, array $options = array())
    {
        $this->options = $options;
        $this->submitted = &$submitted;

        $this->validatePage();
        $this->validateBool('status');
        $this->validateBool('blog_post');
        $this->validateTitle();
        $this->validateDescriptionPage();
        $this->validateMetaTitle();
        $this->validateMetaDescription();
        $this->validateTranslation();
        $this->validateStoreId();
        $this->validateCategoryPage();
        $this->validateUserId(false);
        $this->validateImages();
        $this->validateAlias();
        $this->validateUploadImages('page');

        $this->unsetSubmitted('update');

        return $this->getResult();
    }
693240
public function validateForm(array $input, $early_exit = false)
    {
        $result = new Result($input);
        foreach ($this->rules as $name => $rules) {
            //skip a value if it is not required...
            if (!isset($this->required[$name])) {
                //and not submitted.
                //here 'submitted' means either not existing or failing submitted()
                if (!isset($input[$name]) || !$this->submitted($input[$name])) {
                    continue;
                }
            }
            $this->doValidation($result, $input, $name, $rules, $early_exit);
        }

        return $result;
    }
674435
public function validateSubmitButtons($options = []) {
		$buttons_found = [];
		$names = [];
		foreach ($this->data as $k => $v) {
			foreach (($v['rows'] ?? []) as $k2 => $v2) {
				// find all process submit buttons
				foreach ($v2['elements'] as $k3 => $v3) {
					if (!empty($v3['options']['process_submit'])) {
						if (!isset($buttons_found[$k3])) {
							$buttons_found[$k3] = [];
						}
						$buttons_found[$k3][] = [
							'name' => $v3['options']['value'],
							'key' => [$k, 'rows', $k2, 'elements', $k3]
						];
						$names[$k3] = $v3['options']['value'];
					}
				}
			}
		}
		// validations
		if (!empty($this->buttons_model)) {
			// make a call to master object
			$result = $this->buttons_model->processButtons($this, [
				'skip_validation' => $options['skip_validation'] ?? false
			]);
			$not_allowed = $result['not_allowed'];
			$also_set_save = $result['also_set_save'];
			$all_standard_buttons = $result['all_buttons'];
		} else { // standard buttons
			$all_standard_buttons = [
				self::BUTTON_SUBMIT,
				self::BUTTON_SUBMIT_SAVE,
				self::BUTTON_SUBMIT_SAVE_AND_NEW,
				self::BUTTON_SUBMIT_SAVE_AND_CLOSE,
				self::BUTTON_SUBMIT_RESET,
				self::BUTTON_SUBMIT_DELETE,
				self::BUTTON_CONTINUE,
				self::BUTTON_STOP,
			];
			// process
			$not_allowed = [];
			$show_save_buttons = false;
			if (!empty($this->options['acl_subresource_edit'])) {
				// remove delete buttons if we do not have loaded values or do not have permission
				if (!$this->values_loaded || (empty($this->options['skip_acl']) && !$this->tempProcessACLSubresources($this->options['acl_subresource_edit'], 'Record_Delete'))) {
					$not_allowed[] = self::BUTTON_SUBMIT_DELETE;
				}
				// we need to check permissions
				if (!$this->values_loaded && (empty($this->options['skip_acl']) && $this->tempProcessACLSubresources($this->options['acl_subresource_edit'], 'Record_New'))) {
					$show_save_buttons = true;
				}
				if ($this->values_loaded && (empty($this->options['skip_acl']) && $this->tempProcessACLSubresources($this->options['acl_subresource_edit'], 'Record_Edit'))) {
					$show_save_buttons = true;
				}
			} else {
				// remove delete buttons if we do not have loaded values or do not have permission
				if (!$this->values_loaded || (empty($this->options['skip_acl']) && !\Application::$controller->can('Record_Delete', 'Edit'))) {
					$not_allowed[] = self::BUTTON_SUBMIT_DELETE;
				}
				// we need to check permissions
				if (!$this->values_loaded && (empty($this->options['skip_acl']) && \Application::$controller->can('Record_New', 'Edit'))) {
					$show_save_buttons = true;
				}
				if ($this->values_loaded && (empty($this->options['skip_acl']) && \Application::$controller->can('Record_Edit', 'Edit'))) {
					$show_save_buttons = true;
				}
			}
			if (!$show_save_buttons && empty($this->options['skip_acl'])) {
				$not_allowed[] = self::BUTTON_SUBMIT_SAVE;
				$not_allowed[] = self::BUTTON_SUBMIT_SAVE_AND_NEW;
				$not_allowed[] = self::BUTTON_SUBMIT_SAVE_AND_CLOSE;
				// if we need to make form readonly
				if (!empty($this->options['readonly_if_cannot_edit'])) {
					$this->readonly();
				}
			}
			// these buttons are considered save
			$also_set_save = [
				self::BUTTON_SUBMIT,
				self::BUTTON_SUBMIT_SAVE_AND_NEW,
				self::BUTTON_SUBMIT_SAVE_AND_CLOSE,
				self::BUTTON_SUBMIT_DELETE,
				self::BUTTON_SUBMIT_OTHER_DELETE,
				self::BUTTON_CONTINUE,
				self::BUTTON_STOP
			];
		}
		// validate if we have that button
		$result = true;
		foreach ($buttons_found as $k => $v) {
			if (empty($this->process_submit[$k])) {
				unset($this->process_submit[$k]);
			} else if (empty($buttons_found[$k]) || (!in_array($k, $all_standard_buttons) && empty($this->process_submit_other[$k])) || in_array($k, $not_allowed)) {
				// if we have validation
				if (empty($options['skip_validation'])) {
					$this->error('danger', 'Form action [action] is not allowed!', null, ['replace' => ['[action]' => i18n(null, $names[$k])]]);
					$result = false;
				}
				unset($this->process_submit[$k]);
			}
			// hide it
			if (!empty($options['skip_validation'])) {
				if (!empty($buttons_found[$k]) && in_array($k, $not_allowed)) {
					foreach ($buttons_found[$k] as $v2) {
						// we disable buttons in test mode
						if (\Application::get('flag.numbers.frontend.html.form.show_field_settings')) {
							$temp = array_key_get($this->data, $v2['key']);
							$temp['options']['class'] = ($temp['options']['class'] ?? '') . ' disabled';
							array_key_set($this->data, $v2['key'], $temp);
						} else { // remove in regular mode
							array_key_get($this->data, $v2['key'], ['unset' => true]);
						}
					}
				}
			}
		}
		if ($this->submitted) {
			$this->misc_settings['__original_submitted'] = true;
		}
		$this->submitted = !empty($this->process_submit);
		// fix for save
		foreach ($also_set_save as $v) {
			if (!empty($this->process_submit[$v])) {
				$this->process_submit[self::BUTTON_SUBMIT_SAVE] = true;
			}
		}
		return $result;
	}
60684
public function isValid($value = null, array $options = []): bool
    {
        $this->setOptions($options);
        $this->setValue($value);
        $this->errors = [];

        $this->options['stored-passwords'] = array_reverse($this->options['stored-passwords']);

        $lengthValid = $this->validateLength();
        $letterValid = $this->validateLetter();
        $lowercaseLetterValid = $this->validateLowercaseLetter();
        $uppercaseLetterValid = $this->validateUppercaseLetter();
        $numberValid = $this->validateNumber();
        $specialCharacterValid = $this->validateSpecialCharacter();
        $differentPrevOneValid = $this->validateDifferentPreviousOne();
        $differentPrevAllValid = $this->validateDifferentPreviousAll();

        return $lengthValid
            && $letterValid
            && $lowercaseLetterValid
            && $uppercaseLetterValid
            && $numberValid
            && $specialCharacterValid
            && $differentPrevOneValid
            && $differentPrevAllValid;
    }
432878
public function imageStyle(array &$submitted, array $options = array())
    {
        $this->options = $options;
        $this->submitted = &$submitted;

        $this->validateImageStyle();
        $this->validateName();
        $this->validateBool('status');
        $this->validateActionsImageStyle();

        $this->unsetSubmitted('update');

        return $this->getResult();
    }
950567
public function validate(array $options = null, OutputInterface $output = null) {
		return $this->call_command('validate', $this->prepare_array_input_args($options), $output);
	}
839183
public function run($handler_id, &$submitted, array $options = array())
    {
        $result = null;
        $this->hook->attach('validator.run.before', $submitted, $options, $result, $this);

        if (isset($result)) {
            return $result;
        }

        $result = $this->callHandler($handler_id, $submitted, $options);
        $this->hook->attach('validator.run.after', $submitted, $options, $result, $this);

        if ($result === true) {
            return true;
        }

        return empty($result) ? $this->translation->text('Failed validation') : $result;
    }
1280296
protected function getFieldValidationResults(
        array $fields,
        array $allowedFields = [],
        array $fieldResults = [],
        array $options = []
    ): array {
        foreach ($fields as $fieldName => $value) {
            if (!in_array($fieldName, $allowedFields)) {
                $fieldResults[$fieldName] = new ValidationResultBasic(
                    false,
                    BuildOptionCode::invoke($options, static::CODE_UNRECOGNIZED_FIELD),
                    ['message' => 'Unrecognized field received: (' . $fieldName . ')']
                );
            }
        }

        return $fieldResults;
    }
933762
public function addValidation($property, $validation, $options = array())
    {
        $validations = $this->getValidations($property);
        $validations[$validation] = $options;

        return $this;
    }
1239528
public function valid($options = array())
    {
        $options && $this->setOption($options);

        // Initialize the validation result to be true
        $this->result = true;

        $this->beforeValidate && call_user_func($this->beforeValidate, $this, $this->wei);

        foreach ($this->rules as $field => $rules) {
            $data = $this->getFieldData($field);

            /**
             * Process simple rule
             * FROM
             * 'username' => 'required'
             * TO
             * 'username' => array(
             *     'required' => true
             * )
             */
            if (is_string($rules)) {
                $rules = array($rules => true);
            } elseif ($rules instanceof BaseValidator) {
                $rules = array($rules);
            } elseif (!is_array($rules)) {
                throw new \InvalidArgumentException(sprintf(
                    'Expected argument of type array, string or instance of Wei\Validator\BaseValidator, "%s" given',
                    is_object($rules) ? get_class($rules) : gettype($rules)
                ));
            }

            // Make sure the "required" rule at first
            if (!isset($rules['required'])) {
                $isRequired = true;
            } else {
                $isRequired = (bool) $rules['required'];
                unset($rules['required']);
            }
            $rules = array('required' => $isRequired) + $rules;

            // Start validation
            foreach ($rules as $rule => $params) {
                // Prepare property options for validator
                $props = $this->prepareProps($field, $rule);

                // The current rule validation result
                /* @var $validator Validator\BaseValidator */
                $validator = null;
                $result = $this->validateOne($rule, $data, $params, $validator, $props);

                if (is_object($params)) {
                    $rule = get_class($params);
                }

                // Record the rule validators
                $this->ruleValidators[$field][$rule] = $validator;

                // If any rule is invalid, the result would always be false in the whole validation flow
                if (false === $result) {
                    $this->result = false;
                }

                // Record the valid/invalid rule
                $method = $result ? 'addValidRule' : 'addInvalidRule';
                $this->$method($field, $rule);

                // Trigger the ruleValid/ruleInvalid callback
                $callback = $result ? 'ruleValid' : 'ruleInvalid';
                if ($this->$callback && false === call_user_func($this->$callback, $rule, $field, $this, $this->wei)) {
                    return $this->result;
                }

                if ($result) {
                    // The field data is empty and optional, skip the remaining validation rules
                    /** @var $validator Validator\Required */
                    if ('required' === $rule && $validator->isInvalid($data)) {
                        break;
                    }
                } else {
                    // Break the validation flow when any field's rule is invalid
                    if ('required' === $rule || $this->breakRule || $this->skip) {
                        break;
                    }
                }
            }

            // Trigger the fieldValid/fieldInvalid callback
            $callback = $this->isFieldValid($field) ? 'fieldValid' : 'fieldInvalid';
            if ($this->$callback && false === call_user_func($this->$callback, $field, $this, $this->wei)) {
                return $this->result;
            }

            if (!$this->result && $this->skip) {
                continue;
            }

            // Break the validation flow when any field is invalid
            if (!$this->result && ($this->breakRule || $this->breakField)) {
                break;
            }
        }

        // Trigger the success/failure callback
        $callback = $this->result ? 'success' : 'failure';
        $this->$callback && call_user_func($this->$callback, $this, $this->wei);

        return $this->result;
    }
8386
public function language(array &$submitted, array $options = array())
    {
        $this->options = $options;
        $this->submitted = &$submitted;

        $this->validateLanguage();
        $this->validateWeight();
        $this->validateBool('status');
        $this->validateBool('default');
        $this->validateNameLanguage();
        $this->validateNativeNameLanguage();
        $this->validateCodeLanguage();

        $this->unsetSubmitted('update');

        return $this->getResult();
    }
602582
protected function checkRequiredOptions(array $options)
    {
        array_walk(
            $this->supportedOptions,
            function ($supportedOptionData, $supportedOptionName, $options) {
                if (isset($supportedOptionData[1])
                    && true === $supportedOptionData[1]
                    && empty($supportedOptionData[0])
                    && !array_key_exists($supportedOptionName, $options)
                ) {
                    throw new InvalidServiceOptionsException(
                        'Required validation option not set: ' . $supportedOptionName,
                        1456397839
                    );
                }
            },
            $options
        );
    }
85237
public function validateComponent($handler_id, array $options = array())
    {
        $result = $this->validator->run($handler_id, $this->submitted, $options);

        if ($result === true) {
            return array();
        }

        return $this->errors = (array) $result;
    }
793373
public function fromArray(array $options)
    {
        if (isset($options['Id'])) {
            Validate::isString($options['Id'], 'options[Id]');
            $this->_id = $options['Id'];
        }

        if (isset($options['State'])) {
            Validate::isInteger($options['State'], 'options[State]');
            $this->_state = $options['State'];
        }

        if (isset($options['Created'])) {
            Validate::isDateString($options['Created'], 'options[Created]');
            $this->_created = new \DateTime($options['Created']);
        }

        if (isset($options['LastModified'])) {
            Validate::isDateString(
                $options['LastModified'],
                'options[LastModified]'
            );
            $this->_lastModified = new \DateTime($options['LastModified']);
        }

        if (isset($options['AlternateId'])) {
            Validate::isString($options['AlternateId'], 'options[AlternateId]');
            $this->_alternateId = $options['AlternateId'];
        }

        if (isset($options['Name'])) {
            Validate::isString($options['Name'], 'options[Name]');
            $this->_name = $options['Name'];
        }

        if (isset($options['Options'])) {
            Validate::isInteger($options['Options'], 'options[Options]');
            $this->_options = $options['Options'];
        }

        if (isset($options['Uri'])) {
            Validate::isValidUri($options['Uri'], 'options[Uri]');
            $this->_uri = $options['Uri'];
        }

        if (isset($options['StorageAccountName'])) {
            Validate::isString(
                $options['StorageAccountName'],
                'options[StorageAccountName]'
            );
            $this->_storageAccountName = $options['StorageAccountName'];
        }
    }
1085095
public function city(array &$submitted, array $options = array())
    {
        $this->options = $options;
        $this->submitted = &$submitted;

        $this->validateCity();
        $this->validateBool('status');
        $this->validateName();
        $this->validateStateCity();
        $this->validateZoneCity();
        $this->validateCountryCity();

        $this->unsetSubmitted('update');

        return $this->getResult();
    }
531437
public function product(array &$submitted, array $options = array())
    {
        $this->options = $options;
        $this->submitted = &$submitted;

        $this->validateProduct();
        $this->validateSubtractProduct();
        $this->validateBool('status');
        $this->validateCurrencyProduct();
        $this->validateCategoryProduct();
        $this->validateUnitProduct();
        $this->validatePriceProduct();
        $this->validateStockProduct();
        $this->validateTitle();
        $this->validateDescription();
        $this->validateMetaTitle();
        $this->validateMetaDescription();
        $this->validateTranslation();
        $this->validateImages();
        $this->validateStoreId(false);
        $this->validateUserId(false);
        $this->validateDimensionProduct();
        $this->validateRelatedProduct();
        $this->validateClassProduct();
        $this->validateSkuProduct();
        $this->validateAttributeProduct();
        $this->validateCombinationProduct();
        $this->validateAlias();
        $this->validateUploadImages('product');

        $this->unsetSubmitted('update');

        return $this->getResult();
    }