Documentation ¶
Overview ¶
Package validator
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Error ¶
type Error struct { Field string `json:"field,omitempty"` Message string `json:"message,omitempty"` }
Error is the serializer for a single validation error.
type InternalErrorSerializer ¶
type InternalErrorSerializer struct {
ErrorID string `json:"error_id"`
}
InternalErrorSerializer is the serializer for internal errors. Generally, this is returned when there is an internal error in the application.
Example:
c.Status(fiber.StatusInternalServerError).JSON(common.InternalErrorSerializer{ ErrorID: h.logger.Error(err), })
type ParsingErrorSerializer ¶
type ParsingErrorSerializer struct {
Error string `json:"error"`
}
ParsingErrorSerializer is the serializer for parsing errors. Generally, this is returned when there is an error parsing the request body or query parameters.
Example:
c.Status(fiber.StatusBadRequest).JSON(common.ParsingErrorSerializer{ Error: "error parsing input data", })
type V10 ¶
type V10 struct {
// contains filtered or unexported fields
}
func NewValidatorV10 ¶
func (V10) ValidateStruct ¶
ValidateStruct implements validator.Validator interface.
type ValidationErrorSerializer ¶
type ValidationErrorSerializer struct {
Errors []Error `json:"errors"`
}
ValidationErrorSerializer is the serializer for validation errors. Generally, this is returned when there is an error validating the input/output data.
Example:
c.Status(fiber.StatusBadRequest).JSON(common.ValidationErrorSerializer{ Errors: h.validator.Translate(err), })
type Validator ¶
type Validator interface { // ValidateStruct validates a struct using the validate struct tag. // The input should be a pointer to a struct, and it should have exported fields. ValidateStruct(input any) error // Translate translates the error returned by ValidateStruct to a slice of errors. // that can be used to return to the user. Translate(err error) []Error }
Click to show internal directories.
Click to hide internal directories.