{"id":13431875,"url":"https://github.com/imbrn/v8n","last_synced_at":"2025-05-14T22:05:41.566Z","repository":{"id":37768518,"uuid":"138644245","full_name":"imbrn/v8n","owner":"imbrn","description":"☑️ JavaScript fluent validation library","archived":false,"fork":false,"pushed_at":"2025-01-01T14:55:40.000Z","size":1285,"stargazers_count":4170,"open_issues_count":3,"forks_count":111,"subscribers_count":50,"default_branch":"master","last_synced_at":"2025-04-22T17:05:03.416Z","etag":null,"topics":["javascript","library","validation"],"latest_commit_sha":null,"homepage":"https://imbrn.github.io/v8n","language":"JavaScript","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/imbrn.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":"https://www.buymeacoffee.com/imbrn"}},"created_at":"2018-06-25T20:06:33.000Z","updated_at":"2025-04-15T04:49:39.000Z","dependencies_parsed_at":"2025-03-19T01:30:49.979Z","dependency_job_id":null,"html_url":"https://github.com/imbrn/v8n","commit_stats":{"total_commits":262,"total_committers":14,"mean_commits":"18.714285714285715","dds":"0.23282442748091603","last_synced_commit":"1ac471790accaabfbea7c289d7f0d2abe8214fe1"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imbrn%2Fv8n","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imbrn%2Fv8n/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imbrn%2Fv8n/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imbrn%2Fv8n/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imbrn","download_url":"https://codeload.github.com/imbrn/v8n/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252843825,"owners_count":21812953,"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":["javascript","library","validation"],"created_at":"2024-07-31T02:01:06.670Z","updated_at":"2025-05-07T08:36:42.117Z","avatar_url":"https://github.com/imbrn.png","language":"JavaScript","funding_links":["https://www.buymeacoffee.com/imbrn"],"categories":["JavaScript","Repository","📦 Legacy \u0026 Inactive Projects","Validation","UI Components","Helper Components"],"sub_categories":["Data Validation","Web DB","Form Validation","Reactive Programming"],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./docs/assets/logo.png\" alt=\"v8n\" /\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\nThe ultimate JavaScript validation library you've ever needed.\u003cbr/\u003e\nDead simple fluent API. Customizable. Reusable.\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/imbrn/v8n/actions/workflows/push.yml\"\u003e\n    \u003cimg src=\"https://github.com/imbrn/v8n/actions/workflows/push.yml/badge.svg\" alt=\"Build\" /\u003e\n  \u003c/a\u003e\n  \u003cimg src=\"https://img.shields.io/npm/v/v8n.svg\" alt=\"npm version\" /\u003e\n  \u003cimg src=\"https://img.shields.io/bundlephobia/minzip/v8n.svg\" alt=\"npm bundle size (minified + gzip)\" /\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://imbrn.github.io/v8n/Installation.html\"\u003eInstallation\u003c/a\u003e -\n\u003ca href=\"https://imbrn.github.io/v8n\"\u003eDocumentation\u003c/a\u003e -\n\u003ca href=\"https://imbrn.github.io/v8n/api/\"\u003eAPI\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://www.buymeacoffee.com/imbrn\" target=\"_blank\"\u003e\u003cimg src=\"https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png\" alt=\"Buy Me A Coffee\" style=\"height: auto !important;width: auto !important;\" \u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## Introducing v8n\n\n\u003e **v8n** is an acronym for **v**_alidatio_**n**. Notice that it has exactly\n\u003e eight letters between **v** and **n** in the _\"validation\"_ word. This is the\n\u003e same pattern we are used to seeing with _i18n_, _a11y_, _l10n_ ...\n\n### Chainable API\n\nCreate validations very easily with its chainable API:\n\n```javascript\nv8n()\n  .string()\n  .minLength(5)\n  .first(\"H\")\n  .last(\"o\")\n  .test(\"Hello\"); // true\n```\n\n### Incredibly fluent\n\nMix **rules** and **modifiers** together to create complex validations with\ngreat ease and fluency:\n\n```javascript\nv8n()\n  .array()\n  .every.number()\n  .not.some.negative()\n  .test([1, 2, -3]); // false - no negative please!\n```\n\nSo fluent that it looks like English:\n\n```javascript\nv8n()\n  .some.not.uppercase() // expects that some character is not uppercase\n  .test(\"Hello\"); // true\n\nv8n()\n  .not.some.uppercase() // expects that no character is uppercase\n  .test(\"Hello\"); // false\n```\n\nNotice how we made very different validation strategies just by changing the\norder of the modifiers. It's so intuitive that seems to be impossible, but this\nis v8n.\n\n### Customizable\n\nCreate your own **custom validation rules** in a very intuitive way:\n\n```javascript\nfunction foo() {\n  return value =\u003e value === \"bar\";\n}\n\nv8n.extend({ foo });\n```\n\nv8n will treat them like built-in ones:\n\n```javascript\nv8n()\n  .string()\n  .foo()\n  .test(\"bar\"); // true\n```\n\n### Reusable\n\nExport validations just like you're used to do with your JavaScript modules:\n\n_specialNumber.js_\n\n```javascript\nimport v8n from \"v8n\";\n\nexport default v8n()\n  .number()\n  .between(50, 100)\n  .not.even();\n```\n\nand use them anywhere you want:\n\n```javascript\nimport specialNumber from \"../specialNumber\";\n\nspecialNumber.test(63); // true\n```\n\n### For any kind of data\n\nUse v8n to validate your data regardless of its type. You can validate\nprimitives, arrays, objects and whatever you want! You can also use them\ntogether!\n\n```javascript\n// numbers\nv8n()\n  .number()\n  .between(5, 10)\n  .test(7); //true\n\n// strings\nv8n()\n  .string()\n  .minLength(3)\n  .test(\"foo\"); // true\n\n// arrays\nv8n()\n  .array()\n  .every.even()\n  .test([2, 4, 6]); // true\n\n// objects\nconst myData = { id: \"fe03\" };\n\nv8n()\n  .schema({\n    id: v8n().string()\n  })\n  .test(myData); // true\n```\n\n### For any kind of validation\n\nDo simple validations with boolean based tests. Get more information about your\nvalidation process with exception based tests. And of course, perform\nasynchronous tests as well. All in one library.\n\n#### Boolean based validation:\n\n```javascript\nv8n()\n  .string()\n  .first(\"H\")\n  .test(\"Hello\"); // true\n```\n\n#### Exception based validation:\n\n```javascript\ntry {\n  v8n()\n    .string()\n    .first(\"b\")\n    .check(\"foo\");\n} catch (ex) {\n  console.log(ex.rule.name); // first\n}\n```\n\n#### Getting all failures:\n\n```javascript\nconst failed = v8n()\n  .string()\n  .minLength(3)\n  .testAll(10);\n\nfailed;\n// [\n//   ValidationError { rule: { name: \"string\", ... } },\n//   ValidationError { rule: { name: \"minLength\", ... } }\n// ]\n```\n\n#### Async validation:\n\nIf your validation strategy has some rule that performs time consuming\nvalidation, like a back-end check, you should use asynchronous validation:\n\n```javascript\nv8n()\n  .somAsyncRule()\n  .testAsync(\"foo\") // returns a Promise\n  .then(result =\u003e {\n    /* valid! */\n  })\n  .catch(ex =\u003e {\n    /* invalid! */\n  });\n```\n\n### Shareable\n\nShare your rules with the world, and use theirs as well.\n\nCreate useful validation rules and share them with the open source community,\nand let people around the world validate without reinventing the wheel.\n\n### Ready to use!\n\nThere are a lot of built-in rules and modifiers for you to use already\nimplemented in `v8n`'s core. Take a look at all of them in our\n[API](https://imbrn.github.io/v8n/api/) page. But if you can't find what you\nneed, go ahead and make it.\n\n### Tiny!\n\nAll these incredible features for just a few bytes:\n\n![npm bundle size (minified + gzip)](https://img.shields.io/bundlephobia/minzip/v8n.svg)\n\n## Architecture\n\nThe **v8n** core is composed of `rules` and `modifiers`. They are used together\nto build complex validations in an easy way.\n\n### Rules\n\nRules are the heart of the `v8n` ecosystem. You use them to build your\nvalidation strategies:\n\n```javascript\nv8n()\n  .string()\n  .minLength(3)\n  .test(\"Hello\"); // true\n```\n\nIn this code snippet, we're using two rules (`string` and `minLength`) to build\nour validation strategy. So our validated value (`\"Hello\"`) is valid because\nit's a string and it is at least 3 characters long.\n\n\u003e Rules can be more powerful if used along with _modifiers_. Learn about them in\n\u003e the next section.\n\n### Modifiers\n\nModifiers can be used to change rules meaning. For example, you can use the\n`not` modifier to expect the reversed result from a rule:\n\n```javascript\nv8n()\n  .not.equal(5)\n  .test(5); // false\n```\n\n\u003e You can check all available modifiers on our documentation page.\n\nModifiers are very powerful. They work as decorators for rules. When used\ntogether, they allow you to build very complex validations.\n\n## Contribute\n\nContributions of any kind are welcome! Read our\n[CONTRIBUTING](./.github/CONTRIBUTING.md) guide.\n\n## License\n\n[MIT License](https://opensource.org/licenses/MIT)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimbrn%2Fv8n","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimbrn%2Fv8n","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimbrn%2Fv8n/lists"}