{"id":25655355,"url":"https://github.com/patrickkabwe/go-validator","last_synced_at":"2025-02-23T21:28:44.670Z","repository":{"id":167847540,"uuid":"643476745","full_name":"patrickkabwe/go-validator","owner":"patrickkabwe","description":"Go Validator is a simple package for validating email addresses, URLs, IP addresses, and empty fields in Go. It also provides a way to validate struct fields using struct tags.","archived":false,"fork":false,"pushed_at":"2024-05-12T14:18:58.000Z","size":47,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-15T17:40:44.130Z","etag":null,"topics":["go","go-validation","go-validator","golang","validation"],"latest_commit_sha":null,"homepage":"","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/patrickkabwe.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}},"created_at":"2023-05-21T09:36:47.000Z","updated_at":"2024-05-12T14:18:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"db4ebdf4-76e0-4927-8388-7609b17f1225","html_url":"https://github.com/patrickkabwe/go-validator","commit_stats":null,"previous_names":["kazion500/go-validator","patrickkabwe/go-validator"],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrickkabwe%2Fgo-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrickkabwe%2Fgo-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrickkabwe%2Fgo-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrickkabwe%2Fgo-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/patrickkabwe","download_url":"https://codeload.github.com/patrickkabwe/go-validator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240383451,"owners_count":19792810,"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":["go","go-validation","go-validator","golang","validation"],"created_at":"2025-02-23T21:28:43.962Z","updated_at":"2025-02-23T21:28:44.604Z","avatar_url":"https://github.com/patrickkabwe.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Coverage](https://github.com/Kazion500/go-validator/actions/workflows/coverage.yml/badge.svg)\n\n# Go Validator\n\nGo Validator is a simple package for validating structs, email addresses, URLs, IP addresses, and empty fields in Go. It also provides a way to validate struct fields using struct tags.\n\n## Installation\n\nTo use this package, you need to have Go installed and set up. Then you can run the following command to add the package to your project:\n\n```go\ngo get github.com/patrickkabwe/go-validator\n```\n\n## Features \n\n- 📧 `Email` validation\n- 🌐 `URL` validation\n- 🌐 `IP` address validation\n- 📝 `Empty` field validation\n- 📦 `Struct` validation using struct tags\n- 📊 `Map, Slice, Embedded Struct` validation (Coming Soon)\n\n## Usage\n\nImport the validator package into your Go code:\n\n```go\nimport \"github.com/patrickkabwe/go-validator\"\n```\n\n## Creating a Validator\n\nTo create a new instance of the Validator interface, use the New() function:\n\n```go\nv := validator.New()\n```\n\n### Validating Email Addresses\n\nTo check if a string is a valid email address, use the IsEmail() method:\n\n```go\nok, err := v.IsEmail(email)\nif err != nil {\n    // handle the error\n}\n```\n\n### Checking for Empty Fields\n\nTo validate if a string is empty, use the IsEmpty() method:\n\n```go\n\nvar input = \"\" // empty string\nvar input = \"John Doe\" // non-empty string\n\nok, err := v.IsEmpty(input)\nif err != nil {\n    // handle the error\n}\n```\n\n### Validating URLs\n\nTo validate if a string is a valid URL, use the IsURL() method:\n\n```go\n\nvar input = \"https://example.com\"\n\nok, err := v.IsURL(input)\nif err != nil {\n    // handle the error\n}\n```\n\n### Validating IP Addresses\n\nTo validate if a string is a valid IP address, use the IsIP() method:\n\n```go\n\nvar input = \"127.0.0.1\"\n\nok, err := v.IsIP(input)\nif err != nil {\n    // handle the error\n}\n```\n\n### Validating Structs\n\nTo perform structural validation on a struct, use the ValidateStruct() method. It checks for fields with validate tags and returns a slice of errors:\n\n```go\n\ntype User struct {\n    Name  string `validate:\"required\"`\n    Email string `validate:\"required,email\"`\n}\n\ninput := User{\n    Name:  \"John Doe\",\n    Email: \"test@gmail.com\",\n}\n\nerrors := v.ValidateStruct(input)\nif len(errors) \u003e 0 {\n    // handle the validation errors\n}\n```\n\n\n### Contributing\n\nContributions to this package are welcome. Feel free to submit issues and pull requests on the GitHub repository.\n\n### License\n\nThis package is licensed under the MIT License. See the LICENSE file for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatrickkabwe%2Fgo-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpatrickkabwe%2Fgo-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatrickkabwe%2Fgo-validator/lists"}