{"id":16590345,"url":"https://github.com/jacopkane/legitimate","last_synced_at":"2025-08-01T09:37:26.552Z","repository":{"id":137922819,"uuid":"75447701","full_name":"JacopKane/legitimate","owner":"JacopKane","description":"Functional, modular and async validation 👌","archived":false,"fork":false,"pushed_at":"2018-09-20T04:00:42.000Z","size":2085,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-19T18:41:02.905Z","etag":null,"topics":["async","ecmascript","es2017","javascript","validate","validation"],"latest_commit_sha":null,"homepage":"https://jacopkane.github.io/legitimate/","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JacopKane.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-03T02:52:52.000Z","updated_at":"2023-03-04T06:16:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"e06dad28-8cb7-40c2-8f84-aabc95e086d4","html_url":"https://github.com/JacopKane/legitimate","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacopKane%2Flegitimate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacopKane%2Flegitimate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacopKane%2Flegitimate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacopKane%2Flegitimate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JacopKane","download_url":"https://codeload.github.com/JacopKane/legitimate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242213358,"owners_count":20090693,"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":["async","ecmascript","es2017","javascript","validate","validation"],"created_at":"2024-10-11T23:12:32.583Z","updated_at":"2025-03-06T12:41:27.713Z","avatar_url":"https://github.com/JacopKane.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# legitimate\n\n[![npm][npm-image]][npm-url]\n[![docs][docs-image]][docs-url]\n[![build][travis-image]][travis-url]\n[![codecov][codecov-image]][codecov-url]\n[![dependencies][david-image]][david-url]\n[![version][tag-image]][tag-url]\n\nFunctional, modular and async validation 👌\n\nWorks fine on browser and node.js, framework agnostic.\n\n## [Docs](https://jacopkane.github.io/legitimate/docs \"Docs\")\n\n## [Demo](https://jacopkane.github.io/legitimate/ \"Demo\")\n\n## Installation\n\n```bash\nnpm install --save legitimate\n```\nor\n```bash\nyarn add legitimate\n```\n\n## Usage\n\n#### Simply:\n\n```javascript\nimport { Legitimate, validators } from 'legitimate';\n\nconst legitimate = new Legitimate();\n\nlegitimate\n  .setRules('propToValidate', validators.notEmpty)\n  .update('propToValidate', 'value')\n  .validate('propToValidate') //validates single prop\n  .then(response =\u003e response.map(console.log))\n  .catch(response =\u003e response.map(console.warn));\n```\n\n#### Some customization:\n\n```javascript\nimport { Legitimate, validators, locales } from 'legitimate';\n\nconst legitimate = new Legitimate({\n  ...locales,\n  TOO_SHORT : (value, min) =\u003e `Custom message : ${min}`;\n}, {\n  password : null\n});\n\nconst passwordRules = [\n  password : [\n    validators.isText,\n    validators.notEmpty,\n    (...params) =\u003e validators.min(...params, 8),\n    (...params) =\u003e validators.max(...params, 16),\n    (...params) =\u003e validators.minLowerCaseChars(...params, 1),\n    (...params) =\u003e validators.minUpperCaseChars(...params, 1)\n  ]\n];\n\nlegitimate\n  .setRules('username', validations.notEmpty, validations.alphanumeric)\n  .setRules('password', ...passwordRules)\n  .update('username', 'jacopkane')\n  .update('password', 'secretPass')\n  .isLegit() //validates all the state at once\n  .then(response =\u003e response.map(console.log)) //will return results for all the rules\n  .catch(response =\u003e response.map(console.warn));\n```\n\n#### ES5 \u0026 CommonJS\n\nIf you are old-school, it's fine with ES5 as well.\n\n```javascript\nvar Legitimate = require('legitimate').Legitimate;\nvar legitimate = new Legitimate();\n```\n\n\n## Development\n\n### start demo\n```bash\nnpm start\n```\nor\n```bash\nyarn start\n```\n\n### build\n```bash\nnpm run build\n```\nor\n```bash\nyarn build\n```\n\n### test\n```bash\nnpm test\n```\nor\n```bash\nnpm test -- --coverage\n```\nor\n```bash\nyarn test\n```\n\n### version \u0026 publish\nFor versioning you can use [npm version command](https://docs.npmjs.com/cli/version) with [semver](http://semver.org/)\n\nIt will also\n- test\n- build\n- generate docs\n- stage\n- commit\n- push the tags to tracked remote repository\n- push the demo\n- if CI will pass also get deployed to NPM\n\n```bash\nnpm version patch -f -m \"Backwards-compatible bug fixes\";\n```\nor\n```bash\nnpm version minor -f -m \"Backwards-compatible new functionality\";\n```\nor\n```bash\nyarn version major -f -m \"Made incompatible API changes\";\n```\n\n## TODO\n- Implement / experiment observable approach\n- Simplify demo\n- Add more built-in validators maybe by using other proven libraries\n\n[docs-image]: https://doc.esdoc.org/github.com/JacopKane/legitimate/badge.svg\n[docs-url]: https://jacopkane.github.io/legitimate/docs/\n[npm-image]: https://img.shields.io/npm/v/legitimate.svg\n[npm-url]:https://www.npmjs.org/package/legitimate\n[codecov-image]: https://codecov.io/gh/jacopkane/legitimate/branch/master/graph/badge.svg\n[codecov-url]: https://codecov.io/gh/jacopkane/legitimate\n[travis-url]: https://travis-ci.org/JacopKane/legitimate\n[travis-image]: https://travis-ci.org/JacopKane/legitimate.svg?branch=master\n[david-url]: https://david-dm.org/jacopkane/legitimate?type=dev\n[david-image]: https://david-dm.org/jacopkane/legitimate/dev-status.svg\n[tag-image]: https://img.shields.io/github/tag/jacopkane/legitimate.svg\n[tag-url]: https://github.com/jacopkane/legitimate/tags\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacopkane%2Flegitimate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjacopkane%2Flegitimate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacopkane%2Flegitimate/lists"}