{"id":25722644,"url":"https://github.com/helloooideeeeea/ginformvalidation","last_synced_at":"2025-02-25T19:39:16.598Z","repository":{"id":81492941,"uuid":"238856420","full_name":"helloooideeeeea/GinFormValidation","owner":"helloooideeeeea","description":null,"archived":false,"fork":false,"pushed_at":"2020-02-07T08:38:29.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-23T10:47:18.419Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/helloooideeeeea.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2020-02-07T06:15:12.000Z","updated_at":"2020-02-07T08:08:03.000Z","dependencies_parsed_at":"2023-06-15T01:15:17.767Z","dependency_job_id":null,"html_url":"https://github.com/helloooideeeeea/GinFormValidation","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helloooideeeeea%2FGinFormValidation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helloooideeeeea%2FGinFormValidation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helloooideeeeea%2FGinFormValidation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helloooideeeeea%2FGinFormValidation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/helloooideeeeea","download_url":"https://codeload.github.com/helloooideeeeea/GinFormValidation/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240736855,"owners_count":19849508,"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":[],"created_at":"2025-02-25T19:39:15.891Z","updated_at":"2025-02-25T19:39:16.572Z","avatar_url":"https://github.com/helloooideeeeea.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GinFormValidation\n### this library support validation's Error message for gin  \n\nthis library be able to attach error message-id to binding tag(ex. required)  by struct's meta tag.  \nMaybe this way is simplest for form's validate error message.\n```   \nFormInput `binding: \"validate-attribute\" bind_error: \"validate-attribute=message-id\"`  \n\n//for example,\nFormInput `binding: \"required\" bind_error: \"required=message-id\"`\n// you put bind_error tag.\n```\n\nA serious example\n```go\npackage main\n\nimport (\n\t\"github.com/helloooideeeeea/GinFormValidation\"\n\t\"github.com/gin-gonic/gin\"\n\t\"log\"\n)\n\ntype signInForm struct {\n\tEmail\t\tstring\t\t`binding:\"required,email\" bind_error:\"required=required_email,email=invalid_email\"`\n\tPassword\tstring\t\t`binding:\"required,min=6,max=20\" bind_error:\"required=required_passwd,max=passwd_max, min=passwd_min\"`\n}\n\nfunc main() {\n\tr := gin.Default()\n\tr.POST(\"/signIn\", func(c *gin.Context) {\n\n\t\tvar form signInForm\n\t\tif err := c.BindJSON(\u0026form); err != nil {\n\n\t\t\t//errJson := GinFormValidation.ErrorsToJson(form, err, func(message_id string) string {\n\t\t\t//\treturn translateMessageFromMessageId(message_id) \u003c- if you translate Error message-id, you can do filter message. example, i18n\n\t\t\t//})\n\n\t\t\terrJson := GinFormValidation.ErrorsToJson(form, err, nil)\n\t\t\tc.JSON(400, errJson)\n\t\t\treturn\n\t\t}\n\n\t\tc.String(200, \"OK\")\n\t\treturn\n\t})\n\tif err := r.Run(); err != nil {\n\t\tlog.Fatal(\"Web Server error\", err)\n\t}\n}\n```\n\nlocal test..  \n`$ curl -vvv -X POST -d '{\"Emai\":\"hogehgo\", \"Password\":\"ho\"}' http://localhost:8080/signIn | jq`\n ```json\n{\n  \"errors\": [\n    {\n      \"column\": \"Email\",\n      \"messages\": [\n        \"required_email\"\n      ]\n    },\n    {\n      \"column\": \"Password\",\n      \"messages\": [\n        \"passwd_min\"\n      ]\n    }\n  ]\n} \n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhelloooideeeeea%2Fginformvalidation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhelloooideeeeea%2Fginformvalidation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhelloooideeeeea%2Fginformvalidation/lists"}