{"id":15681634,"url":"https://github.com/idanfishman/fiber-bind","last_synced_at":"2026-01-12T02:44:36.433Z","repository":{"id":157996028,"uuid":"633735428","full_name":"idanfishman/fiber-bind","owner":"idanfishman","description":"🧬 Request schema validator middleware for Fiber","archived":false,"fork":false,"pushed_at":"2024-11-25T21:26:25.000Z","size":59,"stargazers_count":14,"open_issues_count":5,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-06T21:05:03.151Z","etag":null,"topics":["fiber","go","golang","middleware","performance","validation","web"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/idan-fishman/fiber-bind","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/idanfishman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-04-28T06:56:55.000Z","updated_at":"2025-03-24T06:10:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"e8546e0c-67ac-4053-a451-59ddf830c967","html_url":"https://github.com/idanfishman/fiber-bind","commit_stats":null,"previous_names":["idanfishman/fiber-bind","idan-fishman/fiber-bind"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idanfishman%2Ffiber-bind","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idanfishman%2Ffiber-bind/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idanfishman%2Ffiber-bind/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idanfishman%2Ffiber-bind/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/idanfishman","download_url":"https://codeload.github.com/idanfishman/fiber-bind/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252769397,"owners_count":21801376,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fiber","go","golang","middleware","performance","validation","web"],"created_at":"2024-10-03T16:57:59.988Z","updated_at":"2026-01-12T02:44:36.400Z","avatar_url":"https://github.com/idanfishman.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bind Middleware for Fiber\n\n[![Mentioned in Awesome Fiber](https://awesome.re/mentioned-badge.svg)](https://github.com/gofiber/awesome-fiber)\n\nBind is a request schema validator middleware for the [Fiber](https://github.com/gofiber/fiber) web framework. It provides a convenient way to parse and validate data from different sources such as the request body, query string parameters, and route parameters.\n\n## Installation\n\nUse go get to install the middleware:\n\n```bash\ngo get -u github.com/idan-fishman/fiber-bind\n```\n\n## Usage Example\n\nHere are examples of how to use Bind to validate data from the request body and query parameters.\n\n### Body Parameters\n\n```go\npackage main\n\nimport (\n    \"github.com/gofiber/fiber/v2\"\n    \"github.com/idan-fishman/fiber-bind\"\n)\n\ntype Person struct {\n    Name string `json:\"name\" validate:\"required\"`\n    Age  int    `json:\"age\" validate:\"gte=18\"`\n}\n\nfunc main() {\n    app := fiber.New()\n\n    app.Post(\"/person\", bind.New(bind.Config{\n        Validator: validator.New(),\n        Source:    bind.JSON,\n    }, \u0026Person{}), func(c *fiber.Ctx) error {\n        person := c.Locals(bind.JSON).(*Person)\n        return c.JSON(person)\n    })\n\n    app.Listen(\":3000\")\n}\n```\n\n### Query Parameters\n\n```go\npackage main\n\nimport (\n    \"github.com/gofiber/fiber/v2\"\n    \"github.com/idan-fishman/fiber-bind\"\n)\n\ntype PersonParams struct {\n    Name string `json:\"name\" validate:\"required\"`\n}\n\nfunc main() {\n    app := fiber.New()\n\n    app.Get(\"/person\", bind.New(bind.Config{\n        Validator: validator.New(),\n        Source:    bind.Query,\n    }, \u0026PersonParams{}), func(c *fiber.Ctx) error {\n        params := c.Locals(bind.Query).(*PersonParams)\n        return c.JSON(params)\n    })\n\n    app.Listen(\":3000\")\n}\n```\n\nIn these examples, we define a struct that represents the data we want to validate. We then use Bind to validate the data from the request body or query parameters using the `New` function. We specify the source of the data as `bind.Body` or `bind.Query` and provide the struct as the schema to validate against. If the data is valid, it will be available in the context locals for further use.\n\n## Configuration\n\nBind can be configured using the `Config` struct, which has the following fields:\n\n- `Next` - A function that is called before the middleware is executed. If this function returns `true`, the middleware is skipped.\n- `Validator` - A validator instance to use for validating the data. By default, the middleware uses the [go-playground/validator/v10](https://github.com/go-playground/validator/v10) package.\n- `Source` - The source of the data to validate. This can be one of `bind.JSON`, `bind.XML`, `bind.Form`, `bind.Query`, or `bind.Params`.\n- `FormFileFields` - A map where the key is the name of the file field in the form and the value is the form tag. If a field is specified here, the middleware will check if the file is uploaded in the request.\n\n## License\n\nBind is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidanfishman%2Ffiber-bind","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fidanfishman%2Ffiber-bind","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidanfishman%2Ffiber-bind/lists"}