repositorypackage
0.3.0
Repository: https://github.com/camada8/mandragora.git
Documentation: pkg.go.dev
# README
Mandragora validation module for Fiber. Made to ease the development of body, query and path params validation. It is also made to help OpenAPI auto-generation using Gobiru.
⚙️ Installation
To install it simply use this command inside your Fiber project folder:
go get -u github.com/Camada8/mandragora
⚡️ Quickstart
Here's an example of how to use Mandragora to validate your data.
package main
import (
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/log"
m "github.com/Camada8/mandragora" // Importing the Mandragora package for validation
)
type BodyStruct struct {
Foo string `json:"foo" validate:"required,email"`
}
func main() {
app := fiber.New()
// Use the WithValidation middleware to validate the data before the handler executes
app.Post("/", m.WithValidation(m.ValidationConfig{
Body: BodyStruct{},
}), func(c *fiber.Ctx) error {
return c.SendStatus(fiber.StatusOK)
})
// Log the current validation sets for debugging
log.Debug(m.GetValidationSets())
app.Listen(":3000")
}
🧾 License
This project is licensed under the MIT License. See the LICENSE file for details.