{"id":40998747,"url":"https://github.com/maxperrimond/kensho","last_synced_at":"2026-01-22T08:17:59.171Z","repository":{"id":57501608,"uuid":"115680764","full_name":"maxperrimond/kensho","owner":"maxperrimond","description":"A Go validator","archived":false,"fork":false,"pushed_at":"2023-02-23T00:46:39.000Z","size":54,"stargazers_count":4,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-24T09:24:29.420Z","etag":null,"topics":["golang","library","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/maxperrimond.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":"2017-12-29T03:05:24.000Z","updated_at":"2019-10-02T06:06:29.000Z","dependencies_parsed_at":"2022-09-19T09:10:46.084Z","dependency_job_id":null,"html_url":"https://github.com/maxperrimond/kensho","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/maxperrimond/kensho","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxperrimond%2Fkensho","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxperrimond%2Fkensho/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxperrimond%2Fkensho/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxperrimond%2Fkensho/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maxperrimond","download_url":"https://codeload.github.com/maxperrimond/kensho/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxperrimond%2Fkensho/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28659513,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T01:17:37.254Z","status":"online","status_checked_at":"2026-01-22T02:00:07.137Z","response_time":144,"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":["golang","library","validation"],"created_at":"2026-01-22T08:17:58.671Z","updated_at":"2026-01-22T08:17:59.146Z","avatar_url":"https://github.com/maxperrimond.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kenshō - A Go validator\n\n[![Build Status](https://travis-ci.org/maxperrimond/kensho.svg?branch=master)](https://travis-ci.org/maxperrimond/kensho)\n[![Coverage Status](https://coveralls.io/repos/github/maxperrimond/kensho/badge.svg?branch=master)](https://coveralls.io/github/maxperrimond/kensho?branch=master)\n[![Go Report Card](https://goreportcard.com/badge/github.com/maxperrimond/kensho)](https://goreportcard.com/report/github.com/maxperrimond/kensho)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n**A *Work in progress* project so the `master` branch might change in the future and BC breaks some part or change some behaviors.**\n\nA simple Go library for validation, but gives the possibility to validate deeply, collections, any field type of struct by following tag or file.\n\n## TODO\n\n - More docs/examples\n - More tests\n - Add validators\n\n## Features\n\n - Struct validation\n - Able to add custom constraints\n - Validator argument\n - Configuration from a file (ex: json)\n - Deep validation\n - List of struct validation\n - Translation\n\n## Installation\n\n    go get github.com/maxperrimond/kensho\n\n## Usage\n\nHere some code as an example:\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/maxperrimond/kensho\"\n)\n\ntype Group struct {\n\tName  string  `valid:\"required\"`\n\tUsers []*User `valid:\"valid\"` // Ask to valid users if there is some\n}\n\ntype User struct {\n\tEmail     string `valid:\"required,email\"`\n\tFirstName string `valid:\"required,min=2,max=64\"`\n\tLastName  string `valid:\"required,min=2,max=64\"`\n}\n\nfunc main() {\n\t// Simple struct\n\tuser := \u0026User{\n\t\tEmail:     \"foo.bar@example.com\",\n\t\tFirstName: \"foo\",\n\t\tLastName:  \"bar\",\n\t}\n\n\t// Validate user\n\tok, violations, _ := kensho.Validate(user)\n\n\tfmt.Printf(\"Result: %t\\n\", ok)\n\tfmt.Println(violations)\n\n\tuser.Email = \"this is not an email\"\n\tuser.FirstName = \"\"\n\n\t// Validate user after inserting bad data\n\tok, violations, _ = kensho.Validate(user)\n\n\tfmt.Printf(\"Result: %t\\n\", ok)\n\tfmt.Println(violations)\n\n\tusers := []*User{\n\t\t{\n\t\t\tEmail:     \"john@example.com\",\n\t\t\tFirstName: \"john\",\n\t\t\tLastName:  \"bar\",\n\t\t},\n\t\t{\n\t\t\tEmail:     \"pierre@example.com\",\n\t\t\tFirstName: \"pierre\",\n\t\t\tLastName:  \"bar\",\n\t\t},\n\t}\n\n\t// Validate collection of users\n\tok, violations, _ = kensho.Validate(users)\n\n\tfmt.Printf(\"Result: %t\\n\", ok)\n\tfmt.Println(violations)\n\n\t// Nested struct\n\tgroup := \u0026Group{\n\t\tName:  \"foo\",\n\t\tUsers: append(users, user), // With the bad user\n\t}\n\n\t// Validate the group\n\tok, violations, _ = kensho.Validate(group)\n\n\tfmt.Printf(\"Result: %t\\n\", ok)\n\tfmt.Println(violations)\n}\n```\n\n### Available constraints\n\nTag | Arg | Description\n--- | --- | ---\nvalid | | Validate nested struct\nstring | | Check is string\nstruct | | Check is struct\nrequired | | Is required\nlength | int | Match length\nmin | int | Match min length\nmax | int | Match max length\nregex | string (regex pattern) | Match pattern\nemail | | Match email\nuuid | | Match UUID\niso3166 | optional: `num`, `alpha3`, `alpha2` (default) | Match country code based on [IS03166](https://en.wikipedia.org/wiki/ISO_3166)\n\nAnd more to come\n\n### Custom constraint\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"errors\"\n\n\t\"github.com/maxperrimond/kensho\"\n)\n\n// Define your constraint\nfunc poneyConstraint(ctx *kensho.ValidationContext) error {\n\tif ctx.Value() != \"poney\" {\n\t\tctx.BuildViolation(\"invalid_poney\", nil).AddViolation()\n\t}\n\n\treturn nil\n}\n\nfunc init() {\n\t// add it with the tag of your choice\n    kensho.AddConstraint(\"poney\", poneyConstraint)\n}\n```\n\nNote: If you use an existent tag, it will override it.\n\n### Context\n\nYou can pass a context during validation so it can be accessible in constraints:\n\n```go\nok, violations, err := kensho.ValidateWithContext(ctx, subject)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxperrimond%2Fkensho","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxperrimond%2Fkensho","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxperrimond%2Fkensho/lists"}