20 lines
320 B
Go
20 lines
320 B
Go
package errs
|
|
|
|
import "fmt"
|
|
|
|
type ValidationError struct {
|
|
field string
|
|
message string
|
|
}
|
|
|
|
func (e *ValidationError) Error() string {
|
|
return fmt.Sprintf("字段 %s: %s", e.field, e.message)
|
|
}
|
|
|
|
func NewValidationError(field, message string) error {
|
|
return &ValidationError{
|
|
field: field,
|
|
message: message,
|
|
}
|
|
}
|