Returns Login Errors

@param *array $data
@param array  $errors

@return array
558918
public static function getLoginErrors(array $data, array $errors = [])
    {
        //auth_slug        Required
        if (!isset($data['auth_slug']) || empty($data['auth_slug'])) {
            $errors['auth_slug'] = 'Cannot be empty';
        }

        //auth_password        Required
        if (!isset($data['auth_password']) || empty($data['auth_password'])) {
            $errors['auth_password'] = 'Cannot be empty';
        } else {
            $resource = Schema::i('auth')
                ->model()
                ->service('sql')
                ->getResource();

            // check if exists
            $row = $resource
                ->search('auth')
                ->addFilter('auth_slug = %s', $data['auth_slug'])
                ->getRow();

            // if it is not a valid password
            if (
                // both updated hashing
                !password_verify(
                    $data['auth_password'],
                    $row['auth_password']
                )
                // and legacy hashing
                && md5($data['auth_password']) !== $row['auth_password']
            ) {
                //report the error
                $errors['auth_password'] = 'Password is incorrect';
            } else if (
                // does the password need to be upgraded?
                password_needs_rehash(
                    $row['auth_password'],
                    PASSWORD_DEFAULT
                )
            ) {
                //upgrade the hash in the database
                $row['auth_password'] = password_hash(
                    $data['auth_password'],
                    PASSWORD_DEFAULT
                );

                $resource->model($row)->save('auth');
            }
        }

        return $errors;
    }
906390
public function validation($data, $files) {
        $errors = parent::validation($data, $files);

        list($instance, $plugin, $context, $type) = $this->_customdata;

        $pluginerrors = $plugin->edit_instance_validation($data, $files, $instance, $context);

        $errors = array_merge($errors, $pluginerrors);

        return $errors;
    }
1309511
public function errors($reset = true)
    {
        $errors = $this->_errors;
        if ($reset) {
            $this->_errors = array();
        }

        return $errors;
    }
617480
public static function extractResultErrorsInfo(array $result): array
    {
        assert(
            count($result) === 2 &&
            $result[static::REPLY_SUCCESS_VALUE] === null &&
            is_array($result[static::REPLY_ERRORS_INFO]) === true &&
            empty($result[static::REPLY_ERRORS_INFO]) === false
        );

        $value = $result[static::REPLY_ERRORS_INFO];

        return $value;
    }
257919
protected function _toData($errors)
    {
        $data = array();

        foreach ($errors as $error) {
            if ($error instanceof Exception) {
                $data[] = array('code' => $error->getCode(),'message' => $error->getMessage());
            } elseif ($error instanceof AnError) {
                $data[] = $error->toArray();
            }
        }

        return $data;
    }
920451
private function privateErrors() : array
    {
        $errors = [];
        if (isset($this->tests)) {
            foreach ($this->tests as $error => $test) {
                if (!$test((array)$this)) {
                    $errors[] = $error;
                }
            }
        }
        return $errors;
    }
1297118
public static function makeError($errorCode, $message, $data = array())
	{
		$error = array();
		$error['flag'] = false;
		$error['message'] = $message;
		$error['code'] = $errorCode;
		if(!empty($data))
			$error['data'] = $data;

		return $error;
	}
126377
public static function getOptionalErrors(array $data, array $errors = [])
    {
        //validations

        if (isset($data['singular']) && strlen($data['singular']) <= 2) {
            $errors['singular'] = 'Singular should be longer than 2 characters';
        }

        if (isset($data['singular']) && strlen($data['singular']) >= 255) {
            $errors['singular'] = 'Singular should be less than 255 characters';
        }

        if (isset($data['plural']) && strlen($data['plural']) <= 2) {
            $errors['plural'] = 'Plural should be longer than 2 characters';
        }

        if (isset($data['plural']) && strlen($data['plural']) >= 255) {
            $errors['plural'] = 'Plural should be less than 255 characters';
        }

        if (isset($data['name']) && !preg_match('#^[a-zA-Z0-9\-_]+$#', $data['name'])) {
            $errors['name'] = 'Keyword must only have letters, numbers, dashes';
        }

        if (isset($data['relations'])) {
            $relations = [];
            foreach ($data['relations'] as $i => $relation) {
                if (in_array($relation['name'], $relations)) {
                    $errors['relations'] = 'Duplicate Relations';
                    break;
                }

                if (!trim($relation['name'])) {
                    $errors['relations'] = 'Empty relation name';
                    break;
                }

                $relations[] = $relation['name'];
            }
        }

        return $errors;
    }
65635
public static function makeError($message, array $data = [])
    {
        $res = [
            'success' => false,
            'message' => $message,
        ];

        if (!empty($data)) {
            $res['data'] = $data;
        }

        return $res;
    }
138474
private function input($data, $errors = array()){
		$rtn = '';
		foreach( $this->init_cols as $column_name ){
			$column_definition = $this->table_definition->columns->$column_name;
			// var_dump($column_definition);
			if( !$this->exdb->is_editable_column( $column_definition ) ){
				continue;
			}

			$foreign_key_array = null;
			if( $column_definition->foreign_key ){
				$foreign_key = explode( '.', $column_definition->foreign_key );
				$foreign_row = $this->exdb->select(
					$foreign_key[0],
					array(),
					array('limit' => 10000)
				);
				if( is_array($foreign_row) ){
					foreach($foreign_row as $foreign_row_row){
						$foreign_key_array[$foreign_row_row[$foreign_key[1]]] = $foreign_row_row[$foreign_key[1]];
					}
				}
			}

			$type_info = $this->exdb->form_elements()->get_type_info($column_definition->type);
			$form_elm = $this->form_endpoint->render(
				$type_info['templates']['input'],
				array(
					'value'=>@$data[$column_definition->name],
					'name'=>@$column_definition->name,
					'def'=>@$column_definition,
					'select_options'=>@$foreign_key_array,
					'error'=>@$errors[$column_definition->name],
				)
			);
			$rtn .= $this->form_endpoint->render(
				'form_elms_unit.html',
				array(
					'label'=>@$column_definition->label,
					'content'=>$form_elm,
					'def'=>@$column_definition,
					'error'=>@$errors[$column_definition->name],
				)
			);
		}

		$rtn = $this->form_endpoint->render(
			'form_edit.html',
			array(
				'href_backto'=>$this->options['href_backto'],
				'action'=>'?',
				'error'=>@$errors[':common'],
				'content'=>$rtn,
			)
		);

		$rtn = $this->form_endpoint->wrap_theme($rtn);
		return $rtn;
	}
454095
public function errors(array $errors, $code = 0)
    {
        foreach ($errors as $error) {
            $this->error($error, $code);
        }
    }
132340
public function validation($data, $files) {
        $errors = parent::validation($data, $files);

        if ($this->_form->_submitValues['subject'] == 'none') {
            $errors['subject'] = get_string('mustselectsubject', 'hub');
        }

        return $errors;
    }
300913
public function toRet(array $data = [])
    {
        if ($this->isSuccess()) {
            return $this->suc($data + (array) $this->getResponse());
        }

        $e = $this->getErrorException();
        return $this->err($data + ['code' => $e->getCode(), 'message' => $e->getMessage()]);
    }
430754
public static function validate(array $data, array $rules = [], array $messages = []): array
    {
        $errors = [];

        foreach ($rules as $name => $field_rules) {
            if (isset($data[$name])) {
                $field_value = $data[$name];

                $found_err = self::validateFiled($data, $field_value, self::normalizeRules($field_rules), $messages[$name] ?? []);

                if(\is_array($found_err)){
                    $errors[$name] = $found_err;
                }
            }
        }

        return $errors;
    }
620944
public function resetPassword(array $data)
    {
        $result = array();
        $this->hook->attach('user.reset.password.before', $data, $result, $this);

        if (!empty($result)) {
            return (array) $result;
        }

        if (empty($data['user']['user_id'])) {
            return $this->getResultError();
        }

        if (isset($data['password'])) {
            $result = $this->resetPasswordFinish($data);
        } else {
            $result = $this->resetPasswordStart($data);
        }

        $this->session->regenerate(true);
        $this->hook->attach('user.reset.password.after', $data, $result, $this);
        return (array) $result;
    }
60386
private function errorMessages(string $field, array $errors): array {
        $messages = [];

        foreach ($errors as $error) {
            $messages[] = $this->formatErrorMessage($error + ['field' => $field]);
        }
        return $messages;
    }
634561
protected function mergeErrors(array $errors1, array $errors2) {
		foreach($errors2['rules'] as $name=>$rule) {
			if(isset($errors1['rules'][$name])) {
				$i=1;
				while(isset($errors1['rules'][$name.'-'.$i])) { $i += 1; }
				$name = $name.'-'.$i;
			}
			$errors1['rules'][$name] = $rule;
		}
		foreach($errors2['attributes'] as $attribute=>$errors) {
			if(isset($errors1['attributes'][$attribute]))
				$errors1['attributes'][$attribute] = $this->mergeErrors($errors1['attributes'][$attribute], $errors2['attributes'][$attribute]);
			else
				$errors1['attributes'] = $errors2['attributes'];
		}
		return $errors1;
	}