{"id":21871252,"url":"https://github.com/dariomatias-dev/go-validators","last_synced_at":"2026-01-28T22:31:38.494Z","repository":{"id":226605000,"uuid":"759520955","full_name":"dariomatias-dev/go-validators","owner":"dariomatias-dev","description":"Package of validators for GoLang applications.","archived":false,"fork":false,"pushed_at":"2025-08-23T20:10:19.000Z","size":312,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-24T08:18:02.039Z","etag":null,"topics":["go","golang","golang-package","mit","mit-license","open-source","package","validators"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/dariomatias-dev/go-validators","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/dariomatias-dev.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,"zenodo":null}},"created_at":"2024-02-18T20:11:56.000Z","updated_at":"2025-08-23T20:10:22.000Z","dependencies_parsed_at":"2024-06-28T00:20:21.039Z","dependency_job_id":"9519a8a7-79c4-4295-ba17-341e2b1e29d1","html_url":"https://github.com/dariomatias-dev/go-validators","commit_stats":null,"previous_names":["dariomatias-dev/go-validators"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/dariomatias-dev/go-validators","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dariomatias-dev%2Fgo-validators","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dariomatias-dev%2Fgo-validators/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dariomatias-dev%2Fgo-validators/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dariomatias-dev%2Fgo-validators/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dariomatias-dev","download_url":"https://codeload.github.com/dariomatias-dev/go-validators/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dariomatias-dev%2Fgo-validators/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28853535,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T15:15:36.453Z","status":"ssl_error","status_checked_at":"2026-01-28T15:15:13.020Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["go","golang","golang-package","mit","mit-license","open-source","package","validators"],"created_at":"2024-11-28T06:13:47.510Z","updated_at":"2026-01-28T22:31:38.488Z","avatar_url":"https://github.com/dariomatias-dev.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cbr\u003e\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/Go-1.22.3-blue?style=for-the-badge\u0026logo=go\u0026logoColor=white\" alt=\"Go\"\u003e\n\u003c/div\u003e\n\u003cbr\u003e\n\n\u003ch1 align=\"center\"\u003eGo Validators\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  A powerful, lightweight, and dependency-free validation package for Go.\n  \u003cbr\u003e\n  \u003ca href=\"#about-the-project\"\u003e\u003cstrong\u003eExplore the docs »\u003c/strong\u003e\u003c/a\u003e\n  \u003cbr\u003e\u003cbr\u003e\n  \u003ca href=\"https://pkg.go.dev/github.com/dariomatias-dev/go-validators\"\u003epkg.go.dev\u003c/a\u003e\n  ·\n  \u003ca href=\"https://github.com/dariomatias-dev/go-validators/issues\"\u003eReport Bug\u003c/a\u003e\n  ·\n  \u003ca href=\"https://github.com/dariomatias-dev/go-validators/issues\"\u003eRequest Feature\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://pkg.go.dev/github.com/dariomatias-dev/go-validators\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Go-1.21-blue?style=flat-square\u0026logo=go\u0026logoColor=white\" alt=\"Go Version\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://goreportcard.com/report/github.com/dariomatias-dev/go-validators\"\u003e\n    \u003cimg src=\"https://goreportcard.com/badge/github.com/dariomatias-dev/go-validators\" alt=\"Go Report Card\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://pkg.go.dev/github.com/dariomatias-dev/go-validators\"\u003e\n    \u003cimg src=\"https://pkg.go.dev/badge/github.com/dariomatias-dev/go-validators.svg\" alt=\"Go Reference\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/dariomatias-dev/go-validators/blob/main/LICENSE\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/License-MIT-blue.svg\" alt=\"License: MIT\"\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n## Table of Contents\n\n- [About The Project](#about-the-project)\n- [Features](#features)\n- [Built With](#built-with)\n- [Getting Started](#getting-started)\n- [Execution Order](#execution-order)\n- [Usage](#usage)\n- [Available Validators](#available-validators)\n- [Contributing](#contributing)\n- [License](#license)\n- [Author](#author)\n\n## About The Project\n\nGo Validators is a validation package for Go designed to be powerful, lightweight, and dependency-free. It provides a flexible way to handle data validation, allowing developers to declaratively validate structs from JSON payloads using `validates` tags or use individual validation functions for granular control.\n\nThis package is easily integrated into any Go project without introducing external dependencies, offering a simple yet extensible solution for ensuring data integrity.\n\n## Features\n\n- **Struct Validation**: Declaratively validate structs from JSON payloads using `validates` tags.\n- **Standalone Functions**: Use individual validation functions for granular control over any value.\n- **Zero Dependencies**: A lightweight package that can be integrated into any project without external dependencies.\n- **Customizable**: Extend the library with your own logic using the `Custom` validator.\n\n## Built With\n\nThis project was developed using the following core technologies:\n\n- **[Go](https://golang.org/)** – An open-source programming language designed for simplicity, reliability, and efficiency in building scalable software.\n\n## Getting Started\n\nTo get a local copy up and running, follow these steps.\n\n### Installation\n\n```bash\ngo get github.com/dariomatias-dev/go-validators\n```\n\n## Execution Order\n\nValidators should be organized in a three-stage order within `validates` tags:\n\n1. **Presence Validators (`required`)**: Confirm the field exists.\n2. **Type Validators (`isString`, `isInt`, etc.)**: Ensure the value has the correct data type.\n3. **Value Validators (`minLength`, `email`, etc.)**: Apply specific rules to the value's content.\n\nThis order prevents runtime errors by ensuring that value validators never receive an unexpected type.\n\n## Usage\n\nImport the package using an alias for cleaner code:\n\n```go\nimport v \"github.com/dariomatias-dev/go-validators\"\n```\n\n### Struct Validation (via Tags)\n\nValidate a JSON payload by mapping it to a struct with `validates` tags. The `Validate` function returns a map of errors or `nil` on success.\n\n```go\ntype UserModel struct {\n    Name  string `json:\"name\"  validates:\"required;isString;minLength=3;maxLength=20\"`\n    Age   int    `json:\"age\"   validates:\"required;isInt;min=18;max=100\"`\n    Email string `json:\"email\" validates:\"required;email\"`\n}\n\nuser := UserModel{}\n\njsonPayload := `{\n    \"name\":  \"Name\",\n    \"age\":   16,\n    \"email\": \"emailexample@gmail.com\"\n}`\n\nerr := v.Validate(\u0026user, jsonPayload)\nif err != nil {\n    fmt.Println(err)\n    return\n}\n```\n\n### Standalone Validation\n\nValidators are configurable higher-order functions. The first parentheses configure the rule, the second receives the value.\n\n```go\nvalue := 4\nerr, _ := v.Min(3, \"Value must be at least 3.\")(value)\nif err != nil {\n    fmt.Println(err)\n}\n\nvalue = 2\nerr, _ = v.Min(3)(value)\nif err != nil {\n    fmt.Println(err)\n    return\n}\n```\n\n## Available Validators\n\nAll parameters marked with (\\*) are mandatory. Custom error messages are always optional.\n\n| Validator       | Category | Parameters                  | Applicable Value Type               |\n| --------------- | -------- | --------------------------- | ----------------------------------- |\n| Required        | Presence |                             | any                                 |\n| IsString        | Type     |                             | string                              |\n| IsNumber        | Type     |                             | int, float                          |\n| IsInt           | Type     |                             | int                                 |\n| IsFloat         | Type     |                             | float                               |\n| IsBool          | Type     |                             | bool                                |\n| IsArray         | Type     | field validators string\\*   | slice, array                        |\n| IsNullString    | Type     |                             | nil, string                         |\n| IsNullNumber    | Type     |                             | nil, int, float                     |\n| IsNullInt       | Type     |                             | nil, int                            |\n| IsNullFloat     | Type     |                             | nil, float                          |\n| IsNullBool      | Type     |                             | nil, bool                           |\n| IsNullArray     | Type     | field validators string\\*   | nil, slice, array                   |\n| Email           | Value    |                             | string                              |\n| Password        | Value    |                             | string                              |\n| Min             | Value    | minimum value (number)\\*    | int, int32, int64, float32, float64 |\n| Max             | Value    | maximum value (number)\\*    | int, int32, int64, float32, float64 |\n| Length          | Value    | size int\\*                  | string, slice, array                |\n| MinLength       | Value    | minimum size int\\*          | string, slice, array                |\n| MaxLength       | Value    | maximum size int\\*          | string, slice, array                |\n| IsAlpha         | Value    |                             | string                              |\n| IsAlphaNum      | Value    |                             | string                              |\n| IsAlphaSpace    | Value    |                             | string                              |\n| IsAlphaNumSpace | Value    |                             | string                              |\n| StartsWith      | Value    | prefix string\\*             | string                              |\n| StartsNotWith   | Value    | prefix string\\*             | string                              |\n| EndsWith        | Value    | suffix string\\*             | string                              |\n| EndsNotWith     | Value    | suffix string\\*             | string                              |\n| Regex           | Value    | regex string\\*              | string                              |\n| Url             | Value    |                             | string                              |\n| Uuid            | Value    | version int (Default: 5)    | string                              |\n| OneOf           | Value    | options \\[]string\\*         | string                              |\n| Custom          | Value    | custom validator function\\* | any                                 |\n\n## Contributing\n\nContributions make the open-source community an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.\n\n1. Fork the Project\n2. Create your Feature Branch\n\n```sh\ngit checkout -b feature/AmazingFeature\n```\n\n3. Commit your Changes\n\n```sh\ngit commit -m 'Add some AmazingFeature'\n```\n\n4. Push to the Branch\n\n```sh\ngit push origin feature/AmazingFeature\n```\n\n5. Open a Pull Request\n\n## License\n\nDistributed under the **MIT License**. See the [LICENSE](LICENSE) file for more information.\n\n## Author\n\nDeveloped by **Dário Matias**:\n\n- **Portfolio**: [dariomatias-dev](https://dariomatias-dev.com)\n- **GitHub**: [dariomatias-dev](https://github.com/dariomatias-dev)\n- **Email**: [matiasdario75@gmail.com](mailto:matiasdario75@gmail.com)\n- **Instagram**: [@dariomatias_dev](https://instagram.com/dariomatias_dev)\n- **LinkedIn**: [linkedin.com/in/dariomatias-dev](https://linkedin.com/in/dariomatias-dev)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdariomatias-dev%2Fgo-validators","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdariomatias-dev%2Fgo-validators","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdariomatias-dev%2Fgo-validators/lists"}