An open API service providing package, version and dependency metadata of many open source software ecosystems and registries.

Top 7.6% on proxy.golang.org

proxy.golang.org : github.com/H0llyW00dzZ/FiberValidator

Package validator provides a custom validator middleware for the Fiber web framework. It allows for flexible and extensible validation of incoming request bodies. To use this middleware in a Fiber project, Go must be installed and set up. 1. Install the package using Go modules: 2. Import the package in the Fiber application: To use the validator middleware in a Fiber application, create a new instance of the middleware with the desired configuration and register it with the application. In the example above, a new instance of the validator middleware is created with a configuration that restricts the use of Unicode characters in the "name" and "email" fields of the request body. The validator middleware accepts a validator.Config struct for configuration. The available options are: To define custom validation rules, implement the validator.Restrictor interface: The Restrict method takes a Fiber context and returns an error if the validation fails. Here's an example implementation that restricts the use of Unicode characters in specified fields: The validator middleware provides a default error handler that formats the error response based on the content type of the request. It supports JSON, XML, and plain text formats. You can customize the error handling behavior by providing a custom error handler function in the ErrorHandler field of the validator.Config struct. The custom error handler should have the following signature: Example custom error handler: In this example, the custom error handler checks if the error is of type *validator.Error and returns a JSON response with a custom error format.

Registry - Source - Documentation - JSON
purl: pkg:golang/github.com/%21h0lly%21w00dz%21z/%21fiber%21validator
Keywords: gofiber , gofiber-error , golang , golang-package , idiomatic , idiomatic-go , restful-api
License: BSD-3-Clause
Latest release: over 1 year ago
First release: over 1 year ago
Namespace: github.com/H0llyW00dzZ
Stars: 0 on GitHub
Forks: 0 on GitHub
See more repository details: repos.ecosyste.ms
Last synced: 15 days ago

    Loading...
    Readme
    Loading...