validate

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 20, 2026 License: MIT Imports: 4 Imported by: 0

README

validate

该目录只是对外公开的便捷转发层。

  • 面向业务代码提供 gorp/validate 入口
  • 真实实现仍在 framework/*
  • 不在这里承载独立校验实现或新语义

Documentation

Overview

Application scenarios: - Expose the unified validation capability through a top-level convenience package. - Re-export validator contracts so business code can depend on short package paths. - Provide container-based helper functions for object and field validation.

适用场景: - 通过顶层便捷包暴露统一校验能力。 - 重新导出校验器契约,让业务代码可以依赖更短的包路径。 - 提供基于容器的对象校验和字段校验 helper。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

Get returns the unified validator from the container.

Get 从容器获取统一校验器。

func GetOrPanic

GetOrPanic returns the unified validator from the container and panics on failure.

GetOrPanic 从容器获取统一校验器,失败时 panic。

func Validate

func Validate(ctx context.Context, c runtimecontract.Container, obj any) error

Validate validates one object using the validator resolved from the container.

Validate 使用容器中的校验器校验对象。

Example:

err := validate.Validate(ctx, c, &CreateUserRequest{Name: "alice"})

func ValidateVar

func ValidateVar(ctx context.Context, c runtimecontract.Container, field any, tag string) error

ValidateVar validates one field value using the validator resolved from the container.

ValidateVar 使用容器中的校验器校验单个字段值。

Types

type CustomRuleConfig

type CustomRuleConfig = datacontract.CustomRuleConfig

CustomRuleConfig is the top-level alias of the custom rule config contract.

CustomRuleConfig 是自定义规则配置契约的顶层别名。

type CustomValidateFunc

type CustomValidateFunc = datacontract.CustomValidateFunc

CustomValidateFunc is the top-level alias of the custom validate callback contract.

CustomValidateFunc 是自定义校验回调契约的顶层别名。

type ValidationError

type ValidationError = datacontract.ValidationError

ValidationError is the top-level alias of the validation error contract.

ValidationError 是校验错误契约的顶层别名。

type ValidationErrors

type ValidationErrors = datacontract.ValidationErrors

ValidationErrors is the top-level alias of the validation errors contract.

ValidationErrors 是校验错误集合契约的顶层别名。

type Validator

type Validator = datacontract.Validator

Validator is the top-level alias of the unified validator contract.

Validator 是统一校验器契约的顶层别名。

type ValidatorConfig

type ValidatorConfig = datacontract.ValidatorConfig

ValidatorConfig is the top-level alias of the validator config contract.

ValidatorConfig 是校验器配置契约的顶层别名。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL