Documentation ¶
Index ¶
- Constants
- Variables
- func BindParamAndValidate[T interface{}](c *gin.Context, obj *T)
- func SerializeData[T interface{}](source any, target *T) T
- func SerializeDataAndValidate[T interface{}](source T, target *T, doSerialize ...bool) T
- func SuccessHandler(c *gin.Context, responseData interface{})
- func ValidateSchema[T interface{}](source T) T
- func ValidateStruct(i interface{}) error
- type KnownError
Constants ¶
View Source
const ( ErrCodeInternalError = 1000 ErrCodeInvalidParams = 1001 ErrCodeNotFound = 1002 ErrCodeAlreadyExists = 1003 ErrCodeForbidden = 1005 FailedToDeleteNode = 1006 FailedToGetNode = 1007 FailedToAddNode = 1008 FieldError = 2000 FieldInvalid = 2001 FieldTooLong = 2002 FieldTooShort = 2003 FieldTooSmall = 2004 FieldTooBig = 2005 FieldNotMatch = 2006 FieldNotUnique = 2007 EntityNotFound = 2008 )
Variables ¶
View Source
var Validate = validator.New(validator.WithRequiredStructEnabled())
Functions ¶
func BindParamAndValidate ¶
func SerializeData ¶
func SerializeData[T interface{}](source any, target *T) T
func SerializeDataAndValidate ¶
func SerializeDataAndValidate[T interface{}](source T, target *T, doSerialize ...bool) T
func SuccessHandler ¶
SuccessHandler 返回成功响应
func ValidateSchema ¶
func ValidateSchema[T interface{}](source T) T
func ValidateStruct ¶
func ValidateStruct(i interface{}) error
ValidateStruct validates the request structure
Types ¶
type KnownError ¶
func NewKnownError ¶
func NewKnownError(code int, data interface{}, msg string) *KnownError
func (*KnownError) Error ¶
func (e *KnownError) Error() string
Click to show internal directories.
Click to hide internal directories.