{"id":15272396,"url":"https://github.com/gobeam/custom-validator","last_synced_at":"2025-08-19T19:21:32.707Z","repository":{"id":57508096,"uuid":"165019912","full_name":"gobeam/custom-validator","owner":"gobeam","description":"This package was build to beautify the Gin Gonic Binding validation error message for API. You can register your custom validation and easily add customize its message as you like.","archived":false,"fork":false,"pushed_at":"2020-04-26T15:35:39.000Z","size":37,"stargazers_count":14,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-15T02:29:17.017Z","etag":null,"topics":["beautify","custom-validation","gin","golang","golang-package","gonic","middleware","v9","validation-messages","validator"],"latest_commit_sha":null,"homepage":"https://godoc.org/github.com/roshanr83/validator","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/gobeam.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}},"created_at":"2019-01-10T08:21:33.000Z","updated_at":"2022-02-09T13:37:58.000Z","dependencies_parsed_at":"2022-09-19T13:40:43.887Z","dependency_job_id":null,"html_url":"https://github.com/gobeam/custom-validator","commit_stats":null,"previous_names":["roshanr83/validator"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/gobeam/custom-validator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gobeam%2Fcustom-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gobeam%2Fcustom-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gobeam%2Fcustom-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gobeam%2Fcustom-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gobeam","download_url":"https://codeload.github.com/gobeam/custom-validator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gobeam%2Fcustom-validator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271206993,"owners_count":24718705,"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","status":"online","status_checked_at":"2025-08-19T02:00:09.176Z","response_time":63,"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":["beautify","custom-validation","gin","golang","golang-package","gonic","middleware","v9","validation-messages","validator"],"created_at":"2024-09-30T09:05:55.407Z","updated_at":"2025-08-19T19:21:32.676Z","avatar_url":"https://github.com/gobeam.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gin Gonic Custom Validator\n[![Build][Build-Status-Image]][Build-Status-Url] [![Go Report Card](https://goreportcard.com/badge/github.com/gobeam/custom-validator?branch=master)](https://goreportcard.com/report/github.com/gobeam/custom-validator) [![GoDoc][godoc-image]][godoc-url]\n\nThis package was build to beautify Gin Gonic Binding validation error message for api. You can register your own custom validation and easily add customize its message as you like.\nCurrently this package supports gopkg.in/go-playground/validator.v9\n\n## Available Scripts\n\n## Install\n\n```bash\ngo get github.com/gobeam/custom-validator\n```\n\n## Import in your code\n```\nimport \"github.com/gobeam/custom-validator\"\n```\n\n## Simple Examples\n```\nfunc main () {\nrouter := gin.Default()\n\nrouter.Use( validator.Errors())\n\t{\n        router.GET(\"/some-method\", SomeFunction)\n\t}\n\nrouter.Run()\n}\n```\n\n\nIt has default validation message for email, required, min, max, len for extra other validation First you need to register your custom validation by process [here](https://github.com/gin-gonic/gin#custom-validators)\n\nAfter you have successfully registered your custom validator you can register it when application starts in main function to beautify message by:\n\n\n\n```\nfunc main () {\nrouter := gin.Default()\n\nvalidate := []validator.ExtraValidation{\n\t\t{Tag: \"test\", Message:\"%s is passed!\"},\n\t\t{Tag: \"unique\", Message:\"%s must be unique!\"},\n\t}\n\nvalidator.MakeExtraValidation(validate)\n\nrouter.Use( validator.Errors())\n\t{\n        router.GET(\"/some-method\", SomeFunction)\n\t}\n\nrouter.Run()\n}\n\ntype TestModel struct {\n    Name `json:\"name\" binding:required,unique`\n}\n\nfunc SomeFunction (c *gin.Context) {\n    var model TestModel\n\tif err := c.ShouldBindBodyWith(\u0026model, binding.JSON); err != nil {\n\t\t_ = c.AbortWithError(422, err).SetType(gin.ErrorTypeBind)\n\t\treturn\n\t}\n}\n```\n\n\nHere %s in field name which is automatically replaced later and it doesnot matter if the field name is camel case because it will be splitted automatically: for example: \"firstName\" will be outputted as \"First name\". You should name your field name with camelcase only and avoiding _ or underscore. If you have additional param like while specifying length we do len=10 and in message to get that param value just add another \"%s\" in message like \"%s must be of length %s!\" and it will be outputted like \"Field name must be of length 10!\"\n\n\n## Test\n For testing run\n\n ```bash\n go test\n ```\n\n [Build-Status-Url]: https://travis-ci.org/gobeam/custom-validator\n [Build-Status-Image]: https://travis-ci.org/gobeam/custom-validator.svg?branch=master\n [godoc-url]: https://pkg.go.dev/github.com/gobeam/custom-validator?tab=doc\n [godoc-image]: https://godoc.org/github.com/gobeam/custom-validator?status.svg\n \n ## MIT License\n\n```\nCopyright (c) 2019\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgobeam%2Fcustom-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgobeam%2Fcustom-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgobeam%2Fcustom-validator/lists"}