Gets/sets the available validation handlers.

@param  array   $handlers The handlers to set.
@param  boolean $append   Indicating if the handlers need to be appended or replaced.
@return array             The list of available validation handlers
162663
public function handlers($handlers = [], $append = true)
    {
        if (!func_num_args()) {
            $checker = $this->_classes['checker'];
            return $this->_handlers + $checker::handlers();
        }
        if ($append) {
            $this->_handlers = array_merge($this->_handlers, $handlers);
        } else {
            $this->_handlers = $handlers;
        }
        return $this->handlers();
    }
379996
public function getParams(&$errors = null) {
		$ary    = [];
		$fields = $this->__vars;
		foreach ($fields as $field => $v) {
			$value = $this->{$field};
			if (is_null($value)) {
				continue;
			}
			$ary[ $field ] = $value;
		}
		unset($obj, $vars, $var);
		if ($fields) {
			try {
				$this->validateNewData($ary);
			} catch (ValidateException $e) {
				$errors = $e->getErrors();

				return null;
			}
		}

		return $ary;
	}
1296777
protected function checkAllowFields($append = [])
    {
        // 检测字段
        if (empty($this->field) || true === $this->field) {
            $query = $this->db(false);
            $table = $this->table ?: $query->getTable();

            $this->field = $query->getConnection()->getTableFields($table);

            $field = $this->field;
        } else {
            $field = array_merge($this->field, $append);

            if ($this->autoWriteTimestamp) {
                array_push($field, $this->createTime, $this->updateTime);
            }
        }

        if ($this->disuse) {
            // 废弃字段
            $field = array_diff($field, (array) $this->disuse);
        }
        return $field;
    }
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];
    }
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;
	}
1273553
static public function getDomains($append = false)
    {
        $domains = Router::getInstance()->getDomains();
        if ($append) {
            foreach ($domains as &$domain) {
                foreach ($domain as &$path) {
                    $path .= DIRECTORY_SEPARATOR;
                }
            }
        }
        return $domains;
    }
1130283
public static function getUpdateErrors(array $data, array $errors = [])
    {
        if (isset($data['singular']) && empty($data['singular'])) {
            $errors['singular'] = 'Singular is required';
        }

        if (isset($data['plural']) && empty($data['plural'])) {
            $errors['plural'] = 'Plural is required';
        }

        if (isset($data['name']) && empty($data['name'])) {
            $errors['name'] = 'Keyword is required';
        }

        if (!isset($data['fields']) || empty($data['fields'])) {
            $errors['fields'] = 'Fields is required';
        }

        return self::getOptionalErrors($data, $errors);
    }
32023
public function getHandler($handler_id)
    {
        $handlers = $this->getHandlers();
        return empty($handlers[$handler_id]) ? array() : $handlers[$handler_id];
    }
1167171
protected function getValidationRulesFromElements(array $rules = [])
    {
        $this->getElements()->onlyActive()->each(function ($element) use (&$rules) {
            $element = $this->getElementContainer($element);

            if ($element instanceof Validable) {
                $rules += $element->getValidationRules();
            }
        });

        return $rules;
    }
21659
static function validateInputHandlers( &$module, &$class, $object, &$version, $contentObjectAttributes, $editVersion, $editLanguage, $fromLanguage, $validationParameters )
    {
        $result = array( 'validated' => true, 'warnings' => array() );
        $validated =& $result['validated'];
        $warnings =& $result['warnings'];

        $http = eZHTTPTool::instance();

        $functionName = 'validateInput';
        $params = array( $http,
                         &$module,
                         &$class,
                         $object,
                         &$version,
                         $contentObjectAttributes,
                         $editVersion,
                         $editLanguage,
                         $fromLanguage,
                         $validationParameters );

        $validationResults = self::executeHandlerFunction( $functionName, $params );

        foreach( $validationResults as $validationResult )
        {
            $value = $validationResult['function']['value'];

            if ( $value['is_valid'] == false )
            {
                if ( $value['warnings'] )
                    $warnings = array_merge( $warnings, $value['warnings'] );

                $validated = false;
            }
        }

        return $result;
    }
306038
public function setHandlers(array $handlers)
    {
        foreach ($handlers as $handlerName => $handlerCallback)
        {
            $this->setHandler($handlerName, $handlerCallback);
        }

        return $this;
    }
1095125
public function instance_form_validation(array $data, array $files) : array {
        $errors = [];
        $elementname = $this->get_form_element_name();
        if ($this->get_field()->get_configdata_property('uniquevalues') == 1) {
            $value = $data[$elementname];
            if (!$this->is_empty($value) && !$this->is_unique($value)) {
                $errors[$elementname] = get_string('erroruniquevalues', 'core_customfield');
            }
        }
        return $errors;
    }
32490
function appendImageHandler( $handler )
    {
        if ( !$handler )
            return false;
        if ( !$handler->isAvailable() )
            return false;
        $this->ImageHandlers[] = $handler;
        $this->ImageFilters = array_merge( $this->ImageFilters, $handler->supportedImageFilters() );
        $this->ImageFilters = array_unique( $this->ImageFilters );
        return true;
    }
1129406
public function getUpdateErrors(array $data, array &$errors = [], $fieldset = null)
    {
        $schema = $this->schema;

        if (!is_null($fieldset)) {
            $schema = $fieldset;
        }

        $fields = $schema->getFields();
        $table = $schema->getName();
        $primary = $schema->getPrimaryFieldName();

        if ((!isset($data[$primary]) || !is_numeric($data[$primary])) && !is_null($primary)) {
            $errors[$primary] = 'Invalid ID';
        }

        foreach ($fields as $name => $field) {
            if ($field['field']['type'] === 'fieldset') {
                if (!isset($data[$name])) {
                    continue;
                }

                if (!isset($errors[$name])) {
                    $errors[$name] = [];
                }

                if (isset($field['field']['attributes']['data-multiple'])
                    && !$field['field']['attributes']['data-multiple']
                ) {
                    $errors[$name] = $this->getUpdateErrors(
                        $data[$name],
                        $errors[$name],
                        Fieldset::i($field['field']['parameters'])
                    );

                    if (empty($errors[$name])) {
                        unset($errors[$name]);
                    }

                    continue;
                }

                foreach($data[$name] as $index => $row) {
                    if (!isset($errors[$name][$index])) {
                        $errors[$name][$index] = [];
                    }

                    $errors[$name][$index] = $this->getUpdateErrors(
                        $row,
                        $errors[$name][$index],
                        Fieldset::i($field['field']['parameters'])
                    );

                    if (empty($errors[$name][$index])) {
                        unset($errors[$name][$index]);
                    }
                }

                if (empty($errors[$name])) {
                    unset($errors[$name]);
                }

                continue;
            }

            if (!isset($field['validation'])) {
                continue;
            }

            foreach ($field['validation'] as $validation) {
                if ($validation['method'] === 'required'
                    && array_key_exists($name, $data)
                    && empty($data[$name])
                ) {
                    $errors[$name] = $validation['message'];
                }
            }
        }

        return $this->getOptionalErrors($data, $errors, $fieldset);
    }
599505
public static function messages($messages = [], $append = true)
    {
        if (func_num_args()) {
            static::$_messages = $append ? array_merge(static::$_messages, $messages) : $messages + ['_default_' => 'is invalid'];
        }
        return static::$_messages;
    }
275975
public function select($fields, $append = false)
    {
        $fields = is_array($fields) ? $fields : func_get_args();
        if ($append) {
            $this->select = array_merge($this->select, $fields);
        } else {
            $this->select = $fields;
        }
        return $this;
    }
176291
public function hookValidatorHandlers(array &$handlers)
    {
        foreach (array_keys($this->getHandlers()) as $command_id) {
            $class = str_replace('_', '', $command_id);
            $handlers["file_manager_$command_id"] = array(
                'handlers' => array(
                    'validate' => array("gplcart\\modules\\file_manager\\handlers\\validators\\$class", "validate$class")
                ),
            );
        }

        $handlers['file_manager_settings'] = array(
            'handlers' => array(
                'validate' => array('gplcart\\modules\\file_manager\\handlers\\validators\\Settings', 'validateSettings')
            ),
        );
    }