{"id":17462280,"url":"https://github.com/shaunevening/valid-value","last_synced_at":"2025-03-28T06:29:41.615Z","repository":{"id":57390167,"uuid":"129182268","full_name":"ShaunEvening/valid-value","owner":"ShaunEvening","description":"Extendable string validation utility library for typescript and javascript","archived":false,"fork":false,"pushed_at":"2018-04-16T02:50:55.000Z","size":44,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-18T15:49:01.059Z","etag":null,"topics":["es6","extendable","typescript","typescript-library","validation","validator"],"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/ShaunEvening.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}},"created_at":"2018-04-12T02:39:11.000Z","updated_at":"2018-04-16T02:36:48.000Z","dependencies_parsed_at":"2022-09-15T06:01:50.309Z","dependency_job_id":null,"html_url":"https://github.com/ShaunEvening/valid-value","commit_stats":null,"previous_names":["shaunlloyd/valid-value","shaunevening/valid-value"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShaunEvening%2Fvalid-value","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShaunEvening%2Fvalid-value/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShaunEvening%2Fvalid-value/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShaunEvening%2Fvalid-value/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ShaunEvening","download_url":"https://codeload.github.com/ShaunEvening/valid-value/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245983868,"owners_count":20704786,"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":["es6","extendable","typescript","typescript-library","validation","validator"],"created_at":"2024-10-18T08:24:01.764Z","updated_at":"2025-03-28T06:29:41.589Z","avatar_url":"https://github.com/ShaunEvening.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# valid-value\nExtendable validation utility library for typescript and javascript\n\n[![npm version](https://badge.fury.io/js/valid-value.svg)](https://badge.fury.io/js/valid-value)\n\n[![CircleCI](https://circleci.com/gh/ShaunLloyd/valid-value/tree/master.svg?style=shield)](https://circleci.com/gh/ShaunLloyd/valid-value/tree/master)\n\n## Getting Started\n\n```bash\n# Install the package\nnpm install --save valid-value\n\n# Or use yarn\nYarn add valid-value\n\n```\n\n## Contributing\n\n```bash\n# Fork and clone the repository\ngit clone https://github.com/\u003cGITHUB_USERNAME\u003e/valid-value.git\n\n# Move into the directory\ncd valid-value\n\n# Add the main repository as your upstream remote\ngit remote add upstream https://github.com/ShaunLloyd/valid-value.git\n```\n\n**Before contributing, please:**\n- Make sure there is a github issue requesting your fix / addition. This can be from you or someone else.\n\n- Make sure your new code is tested\n\n- Make sure your branch is up to date with the current master branch\n\n## Documentation\n\n### `isValueValid(value: string, validators: ValidatorOrKeyArray) =\u003e boolean`\n\nParams:\n- value - `string`: The string value for validation\n- validators - `Array`: An array of strings keys for the included validators and custom validator functions\n\nReturns: `boolean`\n\n#### Basic Example:\nThis package comes with some built in validators. To use them, add the names of those validators to the validator array. Check our full list of built in validators [here](#built-in-validators)\n\n```ts\nimport { isValueValid } from 'valid-value';\n\nconst isValid = isValueValid('test-string', ['required']);\n\nconsole.log(isValid) // =\u003e returns true\n```\n\n#### Custom Validator Example:\nAdding custom validation rules is easy. Add a function that takes in a string value and returns a boolean.\n\n```ts\nimport { isValueValid } from 'valid-value';\n\nconst isValid = isValueValid('test-4-string', [\n  value =\u003e !/\\d/.test(value), // string must not contain numbers\n]);\n\nconsole.log(isValid) // =\u003e returns false\n```\n\n## Built In Validators\n\nThere are a list of built in validators to use\n\n|  Validator Key | Description |\n|:--------------:|:-----------:|\n|   'required'   | String length must be greater than zero |\n| 'noWhiteSpace' | String must not include any whitespace characters including space, tab, and newline |\n\n## Validator Helpers\n\nThere is also a collection of helper functions to create validators that can be used\n\n### `minimumLength(min: number)`\n\nParams:\n- min - `number`: the minimum length of value\n\nReturns: `(value: string): boolean =\u003e value.length \u003e= min`\n\n`minimumLength` is a function that takes in a number and returns a validator function that checks the string value length is greater than or equal to the given number.\n\n#### Example:\n```ts\nimport { isValueValid } from 'valid-value';\nimport { minimumLength } from 'valid-value/helpers';\n\nconst isValid = isValueValid('test string', [\n  // returns a validator to check for\n  // a minimum length of 5\n  minimumLength(5)\n]);\n```\n---\n### `maximumLength(max: number)`\n\nParams:\n- max - `number`: the maximum length of value\n\nReturns: `(value: string): boolean =\u003e value.length \u003c= max`\n\n`maximumLength` is a function that takes in a number and returns a validator function that checks the string value length is less than or equal to the given number.\n\n#### Example:\n```ts\nimport { isValueValid } from 'valid-value';\nimport { maximumLength } from 'valid-value/helpers';\n\nconst isValid = isValueValid('test string', [\n  // returns a validator to check for\n  // a maximum length of 15\n  maximumLength(15)\n]);\n```\n---\n### `lengthInRange(min: number, max: number)`\n\nParams:\n- min - `number`: the minimum length of value\n- max - `number`: the maximum length of value\n\nReturns: `(value: string): boolean =\u003e value.length \u003e= min \u0026\u0026 value.length \u003c= max`\n\n`lengthInRange` is a function that takes in a minimum and maximum length and returns a validator function that checks the string value length is with in range of the minimum and maximum values inclusive.\n\n#### Example:\n```ts\nimport { isValueValid } from 'valid-value';\nimport { lengthInRange } from 'valid-value/helpers';\n\nconst isValid = isValueValid('test string', [\n  // returns a validator to check for a length\n  // between 5 and 15 inclusive\n  lengthInRange(5, 15)\n]);\n```\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshaunevening%2Fvalid-value","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshaunevening%2Fvalid-value","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshaunevening%2Fvalid-value/lists"}