{"id":18463713,"url":"https://github.com/commandstring/cmdstr-validation","last_synced_at":"2025-10-24T13:12:16.053Z","repository":{"id":255242043,"uuid":"848903928","full_name":"CommandString/cmdstr-validation","owner":"CommandString","description":"An NPM package for simple validation of objects.","archived":false,"fork":false,"pushed_at":"2024-11-14T21:21:21.000Z","size":42,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-16T16:57:58.018Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CommandString.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-08-28T16:07:36.000Z","updated_at":"2024-11-14T21:21:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"61f6bd60-d9c4-4dd9-b13d-cf8f78728a54","html_url":"https://github.com/CommandString/cmdstr-validation","commit_stats":null,"previous_names":["commandstring/ts-validation"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CommandString%2Fcmdstr-validation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CommandString%2Fcmdstr-validation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CommandString%2Fcmdstr-validation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CommandString%2Fcmdstr-validation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CommandString","download_url":"https://codeload.github.com/CommandString/cmdstr-validation/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251319981,"owners_count":21570484,"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":[],"created_at":"2024-11-06T09:07:45.393Z","updated_at":"2025-10-24T13:12:10.991Z","avatar_url":"https://github.com/CommandString.png","language":"TypeScript","readme":"# [cmdstr-validation](https://github.com/commandstring/ts-validation)\nA validation library for validating objects\n\n## Installation\n```\nnpm i cmdstr-validation\n```\n\n## Basic Usage\n\n```js\nconst USERNAME_VALIDATOR = (new ValidationBuilder())  \n    .addField('username', (builder) =\u003e builder  \n\t    .makeRequired('You must have a username!')  \n\t    .addTypeCheck(  \n\t        (v: any) =\u003e typeof v !== 'string',  \n\t        'Invalid username provided!'  \n\t    )  \n\t    .addValidator(  \n\t        (v: string) =\u003e v.length \u003e 50,  \n\t        'Your username cannot exceed 50 characters!'  \n\t    )  \n\t    .addValidator(  \n\t        (v: string) =\u003e v.length \u003c 5,  \n\t        'Your username must not be more than 5 characters!'  \n\t     )  \n\t    .addValidator(  \n\t        (v: string) =\u003e (v.match(/^[a-z_1-9]+$/i) === null),  \n\t        'Your username may only contain letters, underscores, and numbers!'  \n\t    )\n    )\n\nlet usernameErrorBag = USERNAME_VALIDATOR.validate({username: 'Command_String'});\n\nusernameErrorBag.hasErrors // false\nusernameErrorBag.errors // {}\n\nusernameErrorBag = USERNAME_VALIDATOR.validate({username: '$Co'});\nusernameErrorBag.hasErrors // true\nusernameErrorBag.errors /*\n{\n\tusername: [\n\t    'Your username may only contain letters, underscores, and numbers!', \n\t    'Your username must be more than 5 characters!\n\t]\n}\n*/\n\nusernameErrorBag = USERNAME_VALIDATOR.validate({});\nusernameErrorBag.hasErrors // true\nusernameErrorBag.errors /*\n{\n\tusername: [\n\t    'You must have a username!',\n\t]\n} */\n```\n\n*For more complex usage please see the unit tests in `/src/tests/validate.test.ts`*\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcommandstring%2Fcmdstr-validation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcommandstring%2Fcmdstr-validation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcommandstring%2Fcmdstr-validation/lists"}