{"id":37119674,"url":"https://github.com/night-codes/govalidator","last_synced_at":"2026-01-14T13:57:17.359Z","repository":{"id":57495246,"uuid":"54552733","full_name":"night-codes/govalidator","owner":"night-codes","description":"[Go] Package of validators and sanitizers for strings, numerics, slices and structs","archived":false,"fork":true,"pushed_at":"2020-07-01T14:48:24.000Z","size":335,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-14T03:05:11.118Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"asaskevich/govalidator","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/night-codes.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":"2016-03-23T10:56:06.000Z","updated_at":"2020-07-01T14:47:35.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/night-codes/govalidator","commit_stats":null,"previous_names":["mirrr/govalidator"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/night-codes/govalidator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/night-codes%2Fgovalidator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/night-codes%2Fgovalidator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/night-codes%2Fgovalidator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/night-codes%2Fgovalidator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/night-codes","download_url":"https://codeload.github.com/night-codes/govalidator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/night-codes%2Fgovalidator/sbom","scorecard":{"id":686669,"data":{"date":"2025-08-11","repo":{"name":"github.com/night-codes/govalidator","commit":"bfcfe65a8bd8bcfd7ec04af58906518c40c77e57"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-22T01:05:45.401Z","repository_id":57495246,"created_at":"2025-08-22T01:05:45.402Z","updated_at":"2025-08-22T01:05:45.402Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28422384,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T13:30:50.153Z","status":"ssl_error","status_checked_at":"2026-01-14T13:29:08.907Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":[],"created_at":"2026-01-14T13:57:16.692Z","updated_at":"2026-01-14T13:57:17.351Z","avatar_url":"https://github.com/night-codes.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"govalidator\n===========\n[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/night-codes/govalidator?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge) [![GoDoc](https://godoc.org/github.com/night-codes/govalidator?status.svg)](https://pkg.go.dev/github.com/night-codes/govalidator?tab=doc) [![Coverage Status](https://coveralls.io/repos/github/night-codes/govalidator/badge.svg?branch=master)](https://coveralls.io/github/night-codes/govalidator?branch=master)\n\nA package of validators and sanitizers for strings, structs and collections. Based on [validator.js](https://github.com/chriso/validator.js).\n\n#### Installation\nMake sure that Go is installed on your computer.\nType the following command in your terminal:\n\n\tgo get github.com/night-codes/govalidator\n\nAfter it the package is ready to use.\n\n#### Import package in your project\nAdd following line in your `*.go` file:\n```go\nimport \"github.com/night-codes/govalidator\"\n```\n\n#### List of functions:\n```go\nfunc Abs(value float64) float64\nfunc BlackList(str, chars string) string\nfunc ByteLength(str string, params ...string) bool\nfunc StringLength(str string, params ...string) bool\nfunc StringMatches(s string, params ...string) bool\nfunc Min(str string, params ...string) bool\nfunc Max(str string, params ...string) bool\nfunc CamelCaseToUnderscore(str string) string\nfunc Contains(str, substring string) bool\nfunc Count(array []interface{}, iterator ConditionIterator) int\nfunc Each(array []interface{}, iterator Iterator)\nfunc ErrorByField(e error, field string) string\nfunc Filter(array []interface{}, iterator ConditionIterator) []interface{}\nfunc Find(array []interface{}, iterator ConditionIterator) interface{}\nfunc GetLine(s string, index int) (string, error)\nfunc GetLines(s string) []string\nfunc IsHost(s string) bool\nfunc InRange(value, left, right float64) bool\nfunc IsASCII(str string) bool\nfunc IsAlpha(str string) bool\nfunc IsAlphanumeric(str string) bool\nfunc IsBase64(str string) bool\nfunc IsByteLength(str string, min, max int) bool\nfunc IsCreditCard(str string) bool\nfunc IsDataURI(str string) bool\nfunc IsDialString(str string) bool\nfunc IsDNSName(str string) bool\nfunc IsDivisibleBy(str, num string) bool\nfunc IsEmail(str string) bool\nfunc IsFilePath(str string) (bool, int)\nfunc IsFloat(str string) bool\nfunc IsFullWidth(str string) bool\nfunc IsHalfWidth(str string) bool\nfunc IsHexadecimal(str string) bool\nfunc IsHexcolor(str string) bool\nfunc IsIP(str string) bool\nfunc IsIPv4(str string) bool\nfunc IsIPv6(str string) bool\nfunc IsISBN(str string, version int) bool\nfunc IsISBN10(str string) bool\nfunc IsISBN13(str string) bool\nfunc IsISO3166Alpha2(str string) bool\nfunc IsISO3166Alpha3(str string) bool\nfunc IsInt(str string) bool\nfunc IsJSON(str string) bool\nfunc IsLatitude(str string) bool\nfunc IsLongitude(str string) bool\nfunc IsLowerCase(str string) bool\nfunc IsMAC(str string) bool\nfunc IsMongoID(str string) bool\nfunc IsMultibyte(str string) bool\nfunc IsNatural(value float64) bool\nfunc IsNegative(value float64) bool\nfunc IsNonNegative(value float64) bool\nfunc IsNonPositive(value float64) bool\nfunc IsNull(str string) bool\nfunc IsNumeric(str string) bool\nfunc IsPort(str string) bool\nfunc IsPositive(value float64) bool\nfunc IsPrintableASCII(str string) bool\nfunc IsRGBcolor(str string) bool\nfunc IsRequestURI(rawurl string) bool\nfunc IsRequestURL(rawurl string) bool\nfunc IsSSN(str string) bool\nfunc IsSemver(str string) bool\nfunc IsURL(str string) bool\nfunc IsUTFDigit(str string) bool\nfunc IsUTFLetter(str string) bool\nfunc IsUTFLetterNumeric(str string) bool\nfunc IsUTFNumeric(str string) bool\nfunc IsUUID(str string) bool\nfunc IsUUIDv3(str string) bool\nfunc IsUUIDv4(str string) bool\nfunc IsUUIDv5(str string) bool\nfunc IsUpperCase(str string) bool\nfunc IsVariableWidth(str string) bool\nfunc IsWhole(value float64) bool\nfunc LeftTrim(str, chars string) string\nfunc Map(array []interface{}, iterator ResultIterator) []interface{}\nfunc Matches(str, pattern string) bool\nfunc NormalizeEmail(str string) (string, error)\nfunc RemoveTags(s string) string\nfunc ReplacePattern(str, pattern, replace string) string\nfunc Reverse(s string) string\nfunc RightTrim(str, chars string) string\nfunc SafeFileName(str string) string\nfunc Sign(value float64) float64\nfunc StripLow(str string, keepNewLines bool) string\nfunc ToBoolean(str string) (bool, error)\nfunc ToFloat(str string) (float64, error)\nfunc ToInt(str string) (int64, error)\nfunc ToJSON(obj interface{}) (string, error)\nfunc ToString(obj interface{}) string\nfunc Trim(str, chars string) string\nfunc Truncate(str string, length int, ending string) string\nfunc UnderscoreToCamelCase(s string) string\nfunc ValidateStruct(s interface{}) (bool, error)\nfunc WhiteList(str, chars string) string\ntype ConditionIterator\ntype Error\nfunc (e Error) Error() string\ntype Errors\nfunc (es Errors) Error() string\ntype ISO3166Entry\ntype Iterator\ntype ParamValidator\ntype ResultIterator\ntype UnsupportedTypeError\nfunc (e *UnsupportedTypeError) Error() string\ntype Validator\n```\n\n#### Examples\n###### IsURL\n```go\nprintln(govalidator.IsURL(`http://user@pass:domain.com/path/page`))\n```\n###### ToString\n```go\ntype User struct {\n\tFirstName string\n\tLastName string\n}\n\nstr := govalidator.ToString(\u0026User{\"John\", \"Juan\"})\nprintln(str)\n```\n###### Each, Map, Filter, Count for slices\nEach iterates over the slice/array and calls Iterator for every item\n```go\ndata := []interface{}{1, 2, 3, 4, 5}\nvar fn govalidator.Iterator = func(value interface{}, index int) {\n\tprintln(value.(int))\n}\ngovalidator.Each(data, fn)\n```\n```go\ndata := []interface{}{1, 2, 3, 4, 5}\nvar fn govalidator.ResultIterator = func(value interface{}, index int) interface{} {\n\treturn value.(int) * 3\n}\n_ = govalidator.Map(data, fn) // result = []interface{}{1, 6, 9, 12, 15}\n```\n```go\ndata := []interface{}{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}\nvar fn govalidator.ConditionIterator = func(value interface{}, index int) bool {\n\treturn value.(int)%2 == 0\n}\n_ = govalidator.Filter(data, fn) // result = []interface{}{2, 4, 6, 8, 10}\n_ = govalidator.Count(data, fn) // result = 5\n```\n###### ValidateStruct [#2](https://github.com/asaskevich/govalidator/pull/2)\nIf you want to validate structs, you can use tag `valid` for any field in your structure. All validators used with this field in one tag are separated by comma. If you want to skip validation, place `-` in your tag. If you need a validator that is not on the list below, you can add it like this:\n```go\ngovalidator.TagMap[\"duck\"] = govalidator.Validator(func(str string) bool {\n\treturn str == \"duck\"\n})\n```\nHere is a list of available validators for struct fields (validator - used function):\n```go\n\"alpha\":          IsAlpha,\n\"alphanum\":       IsAlphanumeric,\n\"ascii\":          IsASCII,\n\"base64\":         IsBase64,\n\"creditcard\":     IsCreditCard,\n\"datauri\":        IsDataURI,\n\"dialstring\":     IsDialString,\n\"dns\":            IsDNSName,\n\"email\":          IsEmail,\n\"float\":          IsFloat,\n\"fullwidth\":      IsFullWidth,\n\"halfwidth\":      IsHalfWidth,\n\"hexadecimal\":    IsHexadecimal,\n\"hexcolor\":       IsHexcolor,\n\"host\":           IsHost,\n\"int\":            IsInt,\n\"ip\":             IsIP,\n\"ipv4\":           IsIPv4,\n\"ipv6\":           IsIPv6,\n\"isbn10\":         IsISBN10,\n\"isbn13\":         IsISBN13,\n\"json\":           IsJSON,\n\"latitude\":       IsLatitude,\n\"longitude\":      IsLongitude,\n\"lowercase\":      IsLowerCase,\n\"mac\":            IsMAC,\n\"multibyte\":      IsMultibyte,\n\"null\":           IsNull,\n\"numeric\":        IsNumeric,\n\"port\":           IsPort,\n\"printableascii\": IsPrintableASCII,\n\"requri\":         IsRequestURI,\n\"requrl\":         IsRequestURL,\n\"rgbcolor\":       IsRGBcolor,\n\"ssn\":            IsSSN,\n\"semver\":         IsSemver,\n\"uppercase\":      IsUpperCase,\n\"url\":            IsURL,\n\"utfdigit\":       IsUTFDigit,\n\"utfletter\":      IsUTFLetter,\n\"utfletternum\":   IsUTFLetterNumeric,\n\"utfnumeric\":     IsUTFNumeric,\n\"uuid\":           IsUUID,\n\"uuidv3\":         IsUUIDv3,\n\"uuidv4\":         IsUUIDv4,\n\"uuidv5\":         IsUUIDv5,\n\"variablewidth\":  IsVariableWidth,\n```\nValidators with parameters\n\n```go\n\"length(min|max)\"       : ByteLength,\n\"stringlength(min|max)\" : StringLength,\n\"matches(pattern)\"      : StringMatches,\n\"min(min)\"              : Min,\n\"max(max)\"              : Max,\n```\n\nAnd here is small example of usage:\n```go\ntype Post struct {\n\tTitle    string `valid:\"alphanum,required,max(80)\"`\n\tMessage  string `valid:\"duck,ascii\"`\n\tAuthorIP string `valid:\"ipv4\"`\n\tDate     string `valid:\"-\"`\n}\npost := \u0026Post{\n\tTitle:   \"My Example Post\",\n\tMessage: \"duck\",\n\tAuthorIP: \"123.234.54.3\",\n}\n\n// Add your own struct validation tags\ngovalidator.TagMap[\"duck\"] = govalidator.Validator(func(str string) bool {\n\treturn str == \"duck\"\n})\n\nresult, err := govalidator.ValidateStruct(post)\nif err != nil {\n\tprintln(\"error: \" + err.Error())\n}\nprintln(result)\n```\n###### WhiteList\n```go\n// Remove all characters from string ignoring characters between \"a\" and \"z\"\nprintln(govalidator.WhiteList(\"a3a43a5a4a3a2a23a4a5a4a3a4\", \"a-z\") == \"aaaaaaaaaaaa\")\n```\n\n#### Notes\nDocumentation is available here: [godoc.org](https://godoc.org/github.com/asaskevich/govalidator).\nFull information about code coverage is also available here: [govalidator on gocover.io](http://gocover.io/github.com/asaskevich/govalidator).\n\n#### Support\nIf you do have a contribution for the package feel free to put up a Pull Request or open Issue.\n\n#### Special thanks to [contributors](https://github.com/asaskevich/govalidator/graphs/contributors)\n* [Attila Oláh](https://github.com/attilaolah)\n* [Daniel Korner](https://github.com/Dadie)\n* [Steven Wilkin](https://github.com/stevenwilkin)\n* [Deiwin Sarjas](https://github.com/deiwin)\n* [Noah Shibley](https://github.com/slugmobile)\n* [Nathan Davies](https://github.com/nathj07)\n* [Matt Sanford](https://github.com/mzsanford)\n* [Simon ccl1115](https://github.com/ccl1115)\n\n[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/asaskevich/govalidator/trend.png)](https://bitdeli.com/free \"Bitdeli Badge\")\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnight-codes%2Fgovalidator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnight-codes%2Fgovalidator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnight-codes%2Fgovalidator/lists"}