{"id":18327225,"url":"https://github.com/dalikewara/strgo","last_synced_at":"2025-04-09T16:29:57.871Z","repository":{"id":59896950,"uuid":"539077943","full_name":"dalikewara/strgo","owner":"dalikewara","description":"strgo is a helper to validate a string based on a format specification that you set before. You can use this package to validate some common string case like username, name, password, email, etc","archived":false,"fork":false,"pushed_at":"2022-10-04T21:05:43.000Z","size":65,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-15T10:13:24.967Z","etag":null,"topics":["golang","helper","strgo","string","validator"],"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/dalikewara.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"dalikewara","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2022-09-20T16:07:51.000Z","updated_at":"2024-01-26T12:19:22.000Z","dependencies_parsed_at":"2022-09-25T03:30:53.356Z","dependency_job_id":null,"html_url":"https://github.com/dalikewara/strgo","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dalikewara%2Fstrgo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dalikewara%2Fstrgo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dalikewara%2Fstrgo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dalikewara%2Fstrgo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dalikewara","download_url":"https://codeload.github.com/dalikewara/strgo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248067563,"owners_count":21042317,"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":["golang","helper","strgo","string","validator"],"created_at":"2024-11-05T19:09:59.732Z","updated_at":"2025-04-09T16:29:57.850Z","avatar_url":"https://github.com/dalikewara.png","language":"Go","funding_links":["https://github.com/sponsors/dalikewara"],"categories":[],"sub_categories":[],"readme":"# strgo\n\n[![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go\u0026logoColor=white\u0026style=flat-square)](https://pkg.go.dev/github.com/dalikewara/strgo)\n![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/dalikewara/strgo)\n![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/dalikewara/strgo)\n![GitHub license](https://img.shields.io/github/license/dalikewara/strgo)\n\n**strgo** is a helper to validate a string based on a format specification that you set before. You can use this package to validate\nsome common string case like `username`, `name`, `password`, `email`, etc.\n\n## Getting started\n\n### Installation\n\nYou can use the `go get` method:\n\n```bash\ngo get github.com/dalikewara/strgo\n```\n\n### Usage\n\nThis is an example to validate a `username` string:\n\n- `username` can only contain alphanumeric characters, underscores and periods\n- its length must be greater than 2 and not more than 20\n- special character must be followed by at least one alphanumeric character\n- prefix and suffix cannot be a special character\n- allowed special characters must be appeared once in the string\n\n```go\nfunc validate(username string) error {\n    return strgo.Byte(username, \u0026strgo.ByteCondition{\n        MinLength:        3,\n        MaxLength:        20,\n        OnlyContains:     append(strgo.AlphanumericByte, []byte{'_', '.'}...),\n        MustBeFollowedBy: [2][]byte{{'_', '.'}, strgo.AlphanumericByte},\n        MayContainsOnce:  []byte{'_', '.'},\n    })\n}\nvalidate(\"johndoe\") // valid\nvalidate(\"john_doe\") // valid\nvalidate(\"john.doe\") // valid\nvalidate(\"johndoe123\") // valid\nvalidate(\"john.doe123\") // valid\nvalidate(\"john_doe123\") // valid\nvalidate(\"john_doe.123\") // valid\nvalidate(\"_johndoe\") // not valid\nvalidate(\"__johndoe\") // not valid\nvalidate(\".johndoe\") // not valid\nvalidate(\"..johndoe\") // not valid\nvalidate(\"johndoe_\") // not valid\nvalidate(\"johndoe__\") // not valid\nvalidate(\"johndoe.\") // not valid\nvalidate(\"johndoe..\") // not valid\nvalidate(\"john__doe\") // not valid\nvalidate(\"john_.doe\") // not valid\nvalidate(\"john..doe\") // not valid\nvalidate(\"john._doe\") // not valid\nvalidate(\"john@doe\") // not valid\nvalidate(\"@johndoe\") // not valid\nvalidate(\"johndoe@\") // not valid\nvalidate(\"joh_nd_oe\") // not valid\nvalidate(\"joh.nd.oe\") // not valid\n```\n\n...this is an example to validate an `email` string:\n\n- `email` can only contain alphanumeric characters and these special characters: `_.-@+`\n- its length must be greater than 3 and not more than 255\n- special character must be followed by at least one alphanumeric character\n- prefix and suffix cannot be a special character\n- must contain char `@` and must be appeared once in the string\n\n```go\nfunc validate(email string) error {\n    return strgo.Byte(email, \u0026strgo.ByteCondition{\n        MinLength:        4,\n        MaxLength:        255,\n        OnlyContains:     append(strgo.AlphanumericByte, []byte{'_', '.', '@', '-', '+'}...),\n        MustBeFollowedBy: [2][]byte{{'_', '.', '@', '-', '+'}, strgo.AlphanumericByte},\n        MustContainsOnce: []byte{'@'},\n    })\n}\nvalidate(\"johndoe@email.com\") // valid\nvalidate(\"john_doe@email.com\") // valid\nvalidate(\"john_do.e@email.com\") // valid\nvalidate(\"john-doe@email.com\") // valid\nvalidate(\"johndoe@email\") // valid\nvalidate(\"johndoe123@email\") // valid\nvalidate(\"johndoe123@email\") // valid\nvalidate(\"john+doe123@email\") // valid\nvalidate(\"johndoe123email\") // not valid\nvalidate(\"johndoe123.email\") // not valid\nvalidate(\"john@doe123@email\") // not valid\nvalidate(\".johndoe123@email\") // not valid\nvalidate(\"johndoe123@email.\") // not valid\nvalidate(\"johndoe123@\") // not valid\nvalidate(\"john_.doe123@email\") // not valid\nvalidate(\"johndoe123.@email\") // not valid\n```\n\n...and this is an example to validate a `password` string:\n\n- `password` can only contain alphanumeric characters and special characters: !\"#$% \u0026'()*+,-./:;\u003c=\u003e?@[\\]^_`{|}~\n- its length must be greater than 5 and not more than 32\n- at least contain one lower and upper case letter, one number and one special character\n\n```go\nfunc validate(password string) error {\n    return strgo.Byte(password, \u0026strgo.ByteCondition{\n        MinLength:                   6,\n        MaxLength:                   32,\n        OnlyContains:                strgo.CharsByte,\n        AtLeastHaveUpperLetterCount: 1,\n        AtLeastHaveLowerLetterCount: 1,\n        AtLeastHaveNumberCount:      1,\n        AtLeastHaveSpecialCharCount: 1,\n    })\n}\nvalidate(\"J()hndoe123\") // valid\nvalidate(\"John_doe123\") // valid\nvalidate(\"johndoe\") // not valid\nvalidate(\"johndoe123\") // not valid\nvalidate(\"Johndoe123\") // not valid\n```\n\n## Release\n\n### Changelog\n\nRead at [CHANGELOG.md](https://github.com/dalikewara/strgo/blob/master/CHANGELOG.md)\n\n### Credits\n\nCopyright \u0026copy; 2022 [Dali Kewara](https://www.dalikewara.com)\n\n### License\n\n[MIT License](https://github.com/dalikewara/strgo/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdalikewara%2Fstrgo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdalikewara%2Fstrgo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdalikewara%2Fstrgo/lists"}