{"id":19951784,"url":"https://github.com/h0llyw00dzz/fibervalidator","last_synced_at":"2026-06-11T15:31:24.796Z","repository":{"id":240587986,"uuid":"803031278","full_name":"H0llyW00dzZ/fibervalidator","owner":"H0llyW00dzZ","description":"This is a custom validator middleware for the Fiber web framework. It allows defining validation rules for request bodies in various formats, including JSON, XML, and other content types, providing a flexible and extensible way to validate incoming data.","archived":false,"fork":false,"pushed_at":"2026-02-09T15:40:33.000Z","size":74,"stargazers_count":0,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-04-19T11:00:06.762Z","etag":null,"topics":["gofiber","gofiber-error","golang","golang-package","idiomatic","idiomatic-go","restful-api"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/H0llyW00dzZ.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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-05-19T23:06:30.000Z","updated_at":"2025-03-21T05:42:54.000Z","dependencies_parsed_at":"2024-06-19T14:59:26.846Z","dependency_job_id":"b76878e3-584a-4419-adc3-b1c47646405a","html_url":"https://github.com/H0llyW00dzZ/fibervalidator","commit_stats":null,"previous_names":["h0llyw00dzz/fibervalidator"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/H0llyW00dzZ/fibervalidator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/H0llyW00dzZ%2Ffibervalidator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/H0llyW00dzZ%2Ffibervalidator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/H0llyW00dzZ%2Ffibervalidator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/H0llyW00dzZ%2Ffibervalidator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/H0llyW00dzZ","download_url":"https://codeload.github.com/H0llyW00dzZ/fibervalidator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/H0llyW00dzZ%2Ffibervalidator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34206487,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-11T02:00:06.485Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["gofiber","gofiber-error","golang","golang-package","idiomatic","idiomatic-go","restful-api"],"created_at":"2024-11-13T01:09:42.914Z","updated_at":"2026-06-11T15:31:24.732Z","avatar_url":"https://github.com/H0llyW00dzZ.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fiber Validator Middleware\n[![Go Version](https://img.shields.io/badge/1.22.3-gray?style=flat\u0026logo=go\u0026logoWidth=15)](https://github.com/H0llyW00dzZ/FiberValidator/blob/master/go.mod#L3blob/master/go.mod#L3)\n[![Go Reference](https://pkg.go.dev/badge/github.com/H0llyW00dzZ/FiberValidator.svg)](https://pkg.go.dev/github.com/H0llyW00dzZ/FiberValidator) [![Go Report Card](https://goreportcard.com/badge/github.com/H0llyW00dzZ/FiberValidator)](https://goreportcard.com/report/github.com/H0llyW00dzZ/FiberValidator)\n\nThis is a custom validator middleware for the Fiber web framework. It provides a flexible and extensible way to define and apply validation rules to incoming request bodies. The middleware allows for easy validation and sanitization of data, enforcement of specific field requirements, and ensures the integrity of the application's input.\n\n## Features\n\nThe middleware currently supports the following features:\n\n### Request Body Validation\n- Validation of request bodies in various formats, including JSON, XML, and other content types\n- Customizable error handling based on content type\n\n### Unicode Restriction\n- Restriction of Unicode characters in specified fields\n\n### Conditional Validation\n- Conditional validation skipping based on custom logic\n\n### Number Restriction\n- Restriction of fields to contain only numbers with an optional maximum value\n\n### String Length Restriction\n- Restriction of string length for specified fields with a configurable maximum length\n\n### Advanced Use Cases\n- Storing validation results in the request context for advanced use cases\n\nMore features and validation capabilities will be added in the future to enhance the middleware's functionality and cater to a wider range of validation scenarios.\n\n\u003e [!NOTE]  \n\u003e This repository will focus on maintaining and adding more features only for Fiber v2 for the following reasons:\n\u003e - Fiber v2 is already stable\n\u003e - It's easy to implement middleware features that are missing (since I am familiar with many Fiber 2 signatures) or other.\n\n## Benchmark\n\n```sh\ngoos: windows\ngoarch: amd64\npkg: github.com/H0llyW00dzZ/FiberValidator\ncpu: AMD Ryzen 9 3900X 12-Core Processor            \nBenchmarkValidatorWithSonicJSON/Valid_JSON_request-24         \t   45967\t     24768 ns/op\t   16464 B/op\t      86 allocs/op\nBenchmarkValidatorWithStandardJSON/Valid_JSON_request-24      \t   43248\t     27835 ns/op\t   16624 B/op\t     112 allocs/op\nBenchmarkValidatorWithDefaultXML/Valid_XML_request-24         \t   28101\t     42913 ns/op\t   23223 B/op\t     212 allocs/op\nBenchmarkValidatorWithCustomXML/Valid_XML_request-24          \t   28191\t     43596 ns/op\t   23248 B/op\t     212 allocs/op\n```\n\n#### Updated:\n\n```sh\ngoos: windows\ngoarch: amd64\npkg: github.com/H0llyW00dzZ/FiberValidator\ncpu: AMD Ryzen 9 3900X 12-Core Processor            \nBenchmarkValidatorWithSonicJSONSeafood/Valid_JSON_request-24         \t   46785\t     24696 ns/op\t   16447 B/op\t      86 allocs/op\nBenchmarkValidatorWithStandardJSONSeafood/Valid_JSON_request-24      \t   42541\t     28542 ns/op\t   16672 B/op\t     112 allocs/op\nBenchmarkValidatorWithDefaultXMLSeafood/Valid_XML_request-24         \t   26637\t     44806 ns/op\t   23450 B/op\t     213 allocs/op\nBenchmarkValidatorWithCustomXMLSeafood/Valid_XML_request-24          \t   26622\t     45684 ns/op\t   23458 B/op\t     213 allocs/op\nBenchmarkValidatorWithSonicJSON/Valid_JSON_request-24                \t   50625\t     24377 ns/op\t   16410 B/op\t      86 allocs/op\nBenchmarkValidatorWithStandardJSON/Valid_JSON_request-24             \t   42150\t     27954 ns/op\t   16626 B/op\t     112 allocs/op\nBenchmarkValidatorWithDefaultXML/Valid_XML_request-24                \t   27764\t     43721 ns/op\t   23244 B/op\t     212 allocs/op\nBenchmarkValidatorWithCustomXML/Valid_XML_request-24                 \t   27417\t     43951 ns/op\t   23256 B/op\t     212 allocs/op\n```\n\n```sh\ngoos: windows\ngoarch: amd64\npkg: github.com/H0llyW00dzZ/FiberValidator\ncpu: AMD Ryzen 9 3900X 12-Core Processor            \nBenchmarkRestrictStringLengthLongDescriptionSonicJSON/Valid_JSON_long_description-24         \t   55225\t     23263 ns/op\t   19344 B/op\t      58 allocs/op\nBenchmarkRestrictStringLengthLongDescriptionStandardJSON/Valid_JSON_long_description-24      \t   48288\t     24452 ns/op\t   19234 B/op\t      65 allocs/op\nBenchmarkRestrictStringLengthLongDescriptionDefaultXML/Valid_XML_long_description-24         \t   30114\t     39411 ns/op\t   25018 B/op\t     111 allocs/op\nBenchmarkRestrictStringLengthLongDescriptionCustomXML/Valid_XML_long_description-24          \t   30322\t     40180 ns/op\t   25025 B/op\t     111 allocs/op\nBenchmarkValidatorWithSonicJSONSeafood/Valid_JSON_request-24                                 \t   51158\t     23802 ns/op\t   16421 B/op\t      86 allocs/op\nBenchmarkValidatorWithStandardJSONSeafood/Valid_JSON_request-24                              \t   43411\t     27269 ns/op\t   16652 B/op\t     112 allocs/op\nBenchmarkValidatorWithDefaultXMLSeafood/Valid_XML_request-24                                 \t   26984\t     45736 ns/op\t   23451 B/op\t     213 allocs/op\nBenchmarkValidatorWithCustomXMLSeafood/Valid_XML_request-24                                  \t   26899\t     45503 ns/op\t   23443 B/op\t     213 allocs/op\nBenchmarkValidatorWithSonicJSON/Valid_JSON_request-24                                        \t   50936\t     24697 ns/op\t   16417 B/op\t      86 allocs/op\nBenchmarkValidatorWithStandardJSON/Valid_JSON_request-24                                     \t   43172\t     28678 ns/op\t   16627 B/op\t     112 allocs/op\nBenchmarkValidatorWithDefaultXML/Valid_XML_request-24                                        \t   27283\t     43998 ns/op\t   23262 B/op\t     212 allocs/op\nBenchmarkValidatorWithCustomXML/Valid_XML_request-24                                         \t   27990\t     43546 ns/op\t   23264 B/op\t     212 allocs/op\n```\n\n```sh\ngoos: windows\ngoarch: amd64\npkg: github.com/H0llyW00dzZ/FiberValidator\ncpu: AMD Ryzen 9 3900X 12-Core Processor            \nBenchmarkRestrictStringLengthLongDescriptionSonicJSON/Valid_JSON_long_description-24         \t   51478\t     21306 ns/op\t   19331 B/op\t      58 allocs/op\nBenchmarkRestrictStringLengthLongDescriptionStandardJSON/Valid_JSON_long_description-24      \t   47730\t     25044 ns/op\t   19240 B/op\t      65 allocs/op\nBenchmarkRestrictStringLengthLongDescriptionDefaultXML/Valid_XML_long_description-24         \t   30450\t     39450 ns/op\t   25025 B/op\t     111 allocs/op\nBenchmarkRestrictStringLengthLongDescriptionCustomXML/Valid_XML_long_description-24          \t   29910\t     40017 ns/op\t   25025 B/op\t     111 allocs/op\nBenchmarkValidatorWithSonicJSONSeafood/Valid_JSON_request-24                                 \t   60594\t     20457 ns/op\t   14826 B/op\t      68 allocs/op\nBenchmarkValidatorWithStandardJSONSeafood/Valid_JSON_request-24                              \t   50836\t     23481 ns/op\t   15081 B/op\t      94 allocs/op\nBenchmarkValidatorWithDefaultXMLSeafood/Valid_XML_request-24                                 \t   30085\t     40004 ns/op\t   21815 B/op\t     195 allocs/op\nBenchmarkValidatorWithCustomXMLSeafood/Valid_XML_request-24                                  \t   29608\t     40108 ns/op\t   21819 B/op\t     195 allocs/op\nBenchmarkValidatorWithSonicJSON/Valid_JSON_request-24                                        \t   61047\t     20826 ns/op\t   14801 B/op\t      68 allocs/op\nBenchmarkValidatorWithStandardJSON/Valid_JSON_request-24                                     \t   51811\t     23220 ns/op\t   15045 B/op\t      94 allocs/op\nBenchmarkValidatorWithDefaultXML/Valid_XML_request-24                                        \t   31850\t     38777 ns/op\t   21632 B/op\t     194 allocs/op\nBenchmarkValidatorWithCustomXML/Valid_XML_request-24                                         \t   30577\t     39133 ns/op\t   21633 B/op\t     194 allocs/op\n```\n\n\n\u003e [!NOTE]\n\u003e Based on the benchmark results, the following observations can be made:\n\u003e\n\u003e - The Sonic JSON encoder/decoder consistently outperforms the standard JSON encoder/decoder in terms of execution time, bytes allocated, and allocations per operation.\n\u003e - The custom XML encoder/decoder performs slightly slower than the default XML encoder/decoder in most cases, with similar memory usage.\n\u003e - The JSON benchmarks generally have better performance compared to the XML benchmarks, with lower execution time, bytes allocated, and allocations per operation.\n\u003e\n\u003e \u003cp align=\"center\"\u003e\n\u003e   \u003cimg src=\"https://i.imgur.com/PxjZ0Dz.png\" alt=\"gopher run\" /\u003e\n\u003e \u003c/p\u003e\n\u003e\n\u003e Overall, the benchmarks using the Sonic JSON encoder/decoder demonstrate the best performance among the tested scenarios.\n\n## Contributing\n\nContributions are welcome! If there are any issues or suggestions for improvements, please open an issue or submit a pull request.\n\n## License\n\nThis project is licensed under the BSD License. See the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fh0llyw00dzz%2Ffibervalidator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fh0llyw00dzz%2Ffibervalidator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fh0llyw00dzz%2Ffibervalidator/lists"}