Extend the validation function from any other plugin.

@param stdClass $data The form data.
@return array $errors The list of errors keyed by element name.
333012
protected function plugin_extend_coursemodule_validation($data) {
        $errors = array();

        $callbacks = get_plugins_with_function('coursemodule_validation', 'lib.php');
        foreach ($callbacks as $type => $plugins) {
            foreach ($plugins as $plugin => $pluginfunction) {
                // We have exposed all the important properties with public getters - the errors array should be pass by reference.
                $pluginerrors = $pluginfunction($this, $data);
                if (!empty($pluginerrors)) {
                    $errors = array_merge($errors, $pluginerrors);
                }
            }
        }
        return $errors;
    }
163719
public function validation($data, $files) {
        global $DB;

        $errors = parent::validation($data, $files);

        if ($errorcode = course_validate_dates($data['defaults'])) {
            $errors['defaults[enddate]'] = get_string($errorcode, 'error');
        }

        return $errors;
    }
194840
public function validation($data, $files) {

        $pluginman = core_plugin_manager::instance();
        $errors = parent::validation($data, $files);

        if (!empty($data['plugintype'])) {
            if (!$pluginman->is_plugintype_writable($data['plugintype'])) {
                $path = $pluginman->get_plugintype_root($data['plugintype']);
                $errors['plugintype'] = get_string('permcheckresultno', 'tool_installaddon', array('path' => $path));
            }
        }

        return $errors;
    }
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;
    }
595440
private function checkFields(array $data)
    {
        $ruleset = $this->validationRules();
        $mismatch = array_diff_key($data, $ruleset);
        $fields = array_keys($mismatch);

        foreach ($fields as $field) {
            $this->errors[] = array(
                'field' => $field,
                'value' => $data[$field],
                'rule' => 'mismatch',
                'param' => null,
            );
        }

        return $this;
    }
700362
public function validate($data = null)
    {
        if ($data !== null) {
            $this->setData($data);
        }
        // data was already validated, return the results immediately
        if ($this->wasValidated === true) {
            return $this->wasValidated && count($this->messages) === 0;
        }
        foreach ($this->rules as $selector => $valueValidator) {
            foreach ($this->getDataWrapper()->getItemsBySelector($selector) as $valueIdentifier => $value) {
                /* @var $valueValidator \Sirius\Validation\ValueValidator */
                if (!$valueValidator->validate($value, $valueIdentifier, $this->getDataWrapper())) {
                    foreach ($valueValidator->getMessages() as $message) {
                        $this->addMessage($valueIdentifier, $message);
                    }
                }
            }
        }
        $this->wasValidated = true;

        return $this->wasValidated && count($this->messages) === 0;
    }
564388
public static function validate($data, $rules)
	{
		$errors = array();

		foreach ($data as $k => $v)
		{
			if (array_key_exists($k, $rules))
			{
				// (Re)set rule variable
				$rule = null;

				if (is_callable($rules[$k]))
				{
					if ($error = call_user_func_array($rules[$k], [$data]))
					{
						$errors[] = $error;
					}
				}
				else if (strpos($rules[$k], '|'))
				{
					$rule = explode('|', $rules[$k]);
				}
				else
				{
					$rule = array($rules[$k]);
				}

				if (isset($rule))
				{
					foreach ($rule as $r)
					{
						if (method_exists(__CLASS__, $r))
						{
							if ($error = self::$r($k, $v))
							{
								$errors[] = $error;
							}
						}
					}
				}
			}
		}

		return (count($errors) > 0) ? $errors : true;
	}
1254950
function validateAddToBasket( $data, &$errors )
    {
        $dataType = $this->dataType();
        if ( $dataType )
        {
            $this->AddToBasketIsValid = $dataType->validateAddToBasket( $this, $data, $errors );
        }
        return $this->AddToBasketIsValid;
    }
1159215
public function validate($data) {
        // allow paramtype to be a custom regex if it is the form of /pattern/
        if (preg_match('#^/.*/$#', $this->paramtype)) {
            if (preg_match($this->paramtype, $data)) {
                return true;
            } else {
                return get_string('validateerror', 'admin');
            }

        } else if ($this->paramtype === PARAM_RAW) {
            return true;

        } else {
            $cleaned = clean_param($data, $this->paramtype);
            if ("$data" === "$cleaned") { // implicit conversion to string is needed to do exact comparison
                return true;
            } else {
                return get_string('validateerror', 'admin');
            }
        }
    }
238970
protected function validate(array &$data)
    {
        $messages = [];
        if (!empty($data['errors']) && !empty($data['activity']) && !empty($data['requests'])) {
            array_push($messages, ['warning', trans('It is recommended to periodically clean system logs.')]);
        }
        $data = array_merge($data, ['messages' => $messages]);
        return $data;
    }
416585
protected final function validateNewData(array $data = null) {
		if ($data === null && isset($this->_formData)) {
			$data = $this->_formData;
		}
		if ($this->rules) {
			return $this->validateData($this->rules, $data);
		}

		return true;
	}
1338570
public function validation($data, $files = array()) {
        global $DB;

        $errors = array();
        /** @var field_controller $field */
        $field = $this->_customdata['field'];
        $handler = $field->get_handler();

        // Check the shortname is specified and is unique for this component-area-itemid combination.
        if (!preg_match('/^[a-z0-9_]+$/', $data['shortname'])) {
            // Check allowed pattern (numbers, letters and underscore).
            $errors['shortname'] = get_string('invalidshortnameerror', 'core_customfield');
        } else if ($DB->record_exists_sql('SELECT 1 FROM {customfield_field} f ' .
            'JOIN {customfield_category} c ON c.id = f.categoryid ' .
            'WHERE f.shortname = ? AND f.id <> ? AND c.component = ? AND c.area = ? AND c.itemid = ?',
            [$data['shortname'], $data['id'],
                $handler->get_component(), $handler->get_area(), $handler->get_itemid()])) {
            $errors['shortname'] = get_string('formfieldcheckshortname', 'core_customfield');
        }

        $errors = array_merge($errors, $field->config_form_validation($data, $files));

        return $errors;
    }
90293
public function validation($data, $files) {
        global $DB;

        $errors = array();
        if ($DB->count_records('portfolio_instance', array('name' => $data['name'], 'plugin' => $data['plugin'])) > 1) {
            $errors = array('name' => get_string('err_uniquename', 'portfolio'));
        }

        $pluginerrors = array();
        $pluginerrors = portfolio_static_function($this->plugin, 'admin_config_validation', $data);
        if (is_array($pluginerrors)) {
            $errors = array_merge($errors, $pluginerrors);
        }
        return $errors;
    }
1073566
public function implement($data)
	{
		// input validation
		/*$validator = Validator::make($data->toArray(), [
			'position' => 'integer',
			'headline' => 'string',
			'label' => 'string',
			'type' => 'cetype|required',
			'html' => 'string',
			'form_input_type' => "input_type|required_if:type,input",
			'form_params' => 'json',
			'form_options' => 'json',
			#'cssid' => 'alpha_dash',
			#'cssclass' => 'alpha_dash'
		]);

		$validator->sometimes('form_name', 'alpha_dash|required', function ($input) {
			return (($this->type == "input") OR ($this->type == "textarea"));
		});

		$validator->sometimes('html_tag', 'string|required', function ($input) {
			return ($this->type == "wrapper");
		});

		// validation fail
		if($validator->fails())
		{
			\Log::error($validator->errors());
			return false;
		}*/

		// set element type
		$this->type = $data->type;

		// set attributes
		$this->html_attributes = (isset($data->html_attributes)) ? $data->html_attributes : null;

		if($this->type == "text")
		{
			$this->html = $data->html;
		}
		elseif($data->type == "input")
		{
			// set form input type
			$this->form_input_type = $data->form_input_type;

			if(isset($data->form_options))
				$this->form_options = $data->form_options;

			if(isset($data->label))
				$this->label = $data->label;
		}
		elseif($data->type == "wrapper")
		{
			$this->html_tag = $data->html_tag;
			$this->wrapper_type = $data->wrapper_type;
		}
		else
		{
			// error
			return false;
		}

		// successfully created
		return true;
	}
1176143
public function validate(array $data)
    {
        try {
            $messages = $this->validateArray($data, $this->nested);

        } catch (\RuntimeException $e) {
            throw (new ValidationException($e->getMessage(), $e->getCode(), $e))->setMessages();
        }

        if (!empty($messages)) {
            throw (new ValidationException())->setMessages($messages);
        }
    }
266737
public static function getCreateErrors(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';
        }

        if (isset($data['name'])) {
            $exists = false;
            try {
                $exists = Schema::i($data['name'])->getAll();
            } catch (Exception $e) {
            }

            if ($exists) {
                $errors['name'] = 'Schema already exists';
            }
        }

        return self::getOptionalErrors($data, $errors);
    }
1330467
public function optimize (stdClass $data)
    {
        $data->formValidationName = $data->serviceName . 'Validator';
        $data->formValidationNameSpace = str_replace ('\\http\\controllers', '\\validators', $data->controllerNamespace);
        $data->formValidationDestination = str_replace ('/http/controllers', '/validators', $data->controllerDestination) . '/' . $data->formValidationName . '.php';

        if (isset($data->mainModel->multiLanguage)) {
            $data->formTranslationsValidationName = $data->serviceName . 'TranslationsValidator';
            $data->formTranslationsValidationDestination = str_replace ('/http/controllers', '/validators', $data->controllerDestination) . '/' . $data->formTranslationsValidationName . '.php';
        }

        return $data;
    }