Ecosyste.ms: Packages

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

Top 2.8% on proxy.golang.org
Top 5.1% dependent packages on proxy.golang.org
Top 4.8% dependent repos on proxy.golang.org
Top 0.8% forks on proxy.golang.org

proxy.golang.org : gopkg.in/go-playground/validator.v5

Package validator implements value validations for structs and individual fields based on tags. It can also handle Cross Field and Cross Struct validation for nested structs. Validate A simple example usage: The error can be used like so Both StructErrors and FieldError implement the Error interface but it's intended use is for development + debugging, not a production error message. Why not a better error message? because this library intends for you to handle your own error messages Why should I handle my own errors? Many reasons, for us building an internationalized application I needed to know the field and what validation failed so that I could provide an error in the users specific language. The hierarchical error structure is hard to work with sometimes.. Agreed Flatten function to the rescue! Flatten will return a map of FieldError's but the field name will be namespaced. Custom functions can be added Cross Field Validation can be implemented, for example Start & End Date range validation Multiple validators on a field will process in the order defined Bad Validator definitions are not handled by the library NOTE: Baked In Cross field validation only compares fields on the same struct, if cross field + cross struct validation is needed your own custom validator should be implemented. NOTE2: comma is the default separator of validation tags, if you wish to have a comma included within the parameter i.e. excludesall=, you will need to use the UTF-8 hex representation 0x2C, which is replaced in the code as a comma, so the above will become excludesall=0x2C Here is a list of the current built in validators: Validator notes: This package panics when bad input is provided, this is by design, bad code like that should not make it to production.

Registry - Source - Documentation - JSON
purl: pkg:golang/gopkg.in/go-playground/validator.v5
Keywords: error-handling, translation, validation
License: MIT
Latest release: almost 9 years ago
First release: about 9 years ago
Namespace: gopkg.in/go-playground
Dependent packages: 1
Dependent repositories: 1
Stars: 14,709 on GitHub
Forks: 1,234 on GitHub
Total Commits: 696
Committers: 202
Average commits per author: 3.446
Development Distribution Score (DDS): 0.675
More commit stats: commits.ecosyste.ms
See more repository details: repos.ecosyste.ms
Last synced: about 17 hours ago

    Loading...
    Readme
    Loading...