Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(validators ...CustomValidator) plugins.Plugin
New returns an validator plugin. It accepts a list of CustomValidator functions.
By default, it will validate the struct with the Validate() method. If the struct does not have a Validate() method, it will be skipped.
If you want to add custom validation, you can pass a list of CustomValidator functions. The CustomValidator function should accept an interface{} and return an error.
Example:
type MyStruct struct {
Str string
}
func (m MyStruct) Validate() error {
if m.Str == "" {
return fmt.Errorf("Str is empty")
}
return nil
}
Types ¶
type CustomValidator ¶
Click to show internal directories.
Click to hide internal directories.