-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathparam.go
More file actions
27 lines (24 loc) · 964 Bytes
/
param.go
File metadata and controls
27 lines (24 loc) · 964 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package ginvalidator
// Param is used to validate data from the gins route parameters.
type Param struct {
field string // the field to be specified
errFmtFunc ErrFmtFuncHandler // the function to create the error message
}
// Chain initializes a validation chain for the given body field.
// It creates a new ValidationChain object that will validate the specified field
// and format error messages using the provided ErrFmtFuncHandler.
func (p Param) Chain() ValidationChain {
return NewValidationChain(p.field, p.errFmtFunc, ParamLocation)
}
// NewParam constructs a Param validator for the given field.
// Returns a [Param] object that can be used to create validation chains.
//
// Parameters:
// - field: the name of the field to validate.
// - errFmtFunc: a handler for formatting error messages.
func NewParam(field string, errFmtFunc ErrFmtFuncHandler) Param {
return Param{
field: field,
errFmtFunc: errFmtFunc,
}
}