{"id":15668220,"url":"https://github.com/konstantinsimeonov/fluent-schemer","last_synced_at":"2025-04-30T22:26:19.850Z","repository":{"id":57238978,"uuid":"79612126","full_name":"KonstantinSimeonov/fluent-schemer","owner":"KonstantinSimeonov","description":"i wrote this so i can validate stuff without suffering","archived":false,"fork":false,"pushed_at":"2018-09-27T23:25:15.000Z","size":514,"stargazers_count":47,"open_issues_count":1,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-29T05:47:55.327Z","etag":null,"topics":["declarative","javascript","schema-validation","validation","validation-library"],"latest_commit_sha":null,"homepage":"","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/KonstantinSimeonov.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-21T00:23:03.000Z","updated_at":"2023-12-10T01:38:04.000Z","dependencies_parsed_at":"2022-09-05T07:51:16.570Z","dependency_job_id":null,"html_url":"https://github.com/KonstantinSimeonov/fluent-schemer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KonstantinSimeonov%2Ffluent-schemer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KonstantinSimeonov%2Ffluent-schemer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KonstantinSimeonov%2Ffluent-schemer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KonstantinSimeonov%2Ffluent-schemer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KonstantinSimeonov","download_url":"https://codeload.github.com/KonstantinSimeonov/fluent-schemer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251790784,"owners_count":21644288,"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":["declarative","javascript","schema-validation","validation","validation-library"],"created_at":"2024-10-03T14:07:09.735Z","updated_at":"2025-04-30T22:26:19.833Z","avatar_url":"https://github.com/KonstantinSimeonov.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fluent-schemer\n\n\u003ca href='https://travis-ci.org/KonstantinSimeonov/fluent-schemer'\u003e\u003cimg src='https://travis-ci.org/KonstantinSimeonov/fluent-schemer.svg?branch=master' alt='Coverage Status' /\u003e\u003c/a\u003e \u003ca href='https://coveralls.io/github/KonstantinSimeonov/fluent-schemer'\u003e\u003cimg src='https://coveralls.io/repos/github/KonstantinSimeonov/fluent-schemer/badge.svg' alt='Coverage Status' /\u003e\u003c/a\u003e\n\n```js\nconst librarySchema = object({\n\tdependenciesCount: number().min(0).max(10).integer().optional(),\n\tname: string().minlength(2).maxlength(10),\n\ttestCoverage: number().min(0).max(100).optional(),\n\tlastCommitDate: date().after(new Date(new Date().setMonth(new Date().getMonth() - 1))),\n\tcontributors: array(\n\t\tobject({\n\t\t\tusername: string().minlength(5),\n\t\t\temail: string().pattern(/\\S+@\\S+\\.\\S+/)\n\t\t})\n\t),\n\tissues: array(string()),\n\tactivelyMaintained: bool(),\n\tlicense: enumeration('MIT', 'BSD', 'GPL')\n});\n\nconst { errorCounts, errors } = librarySchema.validate(someLibraryRecord);\n```\n\n## Incoming:\n- **default values**, something like\n\n```ts\nconst { corrected: pageSize } = number().min(10).max(100).integer().default(10).validate(-5);\nconsole.log(corrected); // 10\n\nconst { corrected: username } = string()\n\t.minlength(2)\n\t.maxlength(10)\n\t.defaultExpression(value =\u003e ('_________' + value).slice(0, 10))\n\t.validate('1');\nconsole.log(username); // _________1\n```\n\nAims to provide declarative, expressive and elegant approach to validation, while providing an intuitive, easy-to-use api.\n\n## It's cool, because\n- it **fully embraces ES2015** features such as classes, fat arrow functions, mixins, destructuring statements, modules\n- has **typescript type definitions** - v2.0 comes with typings for enhanced development experience\n- has **flow libdefs**, which will soon be available on flow-typed\n- **easy to use and pick up**, write a little code for a lot of common validation logic\n- has a **fluent, readable and declarative** api\n- **umd compliant** - use in node/browser, with commonjs, umd, script tags, harmony modules, whatever\n- **no production dependencies**, small codebase\n- helps developers **get rid of imperative code, long if-else's** and writing boring validations all over again\n- **promotes code reuse** - easily share code between modules, between clients, servers and across projects\n- easy to extends with custom schemas\n- **statically type checked** with latest typescript, checked for correctness with a bunch of **unit tests**\n- **throws errors when rubbish arguments are provided** to schema methods, instead of failing silently\n\n### Running the tests\n\n```\nyarn build \u0026\u0026 yarn lint \u0026\u0026 yarn test\n```\n\n### Examples\n\nExamples can be found in the [docs](./docs), in the source code and in the tests.\n\n## [Documentation](./docs/QUICKSTART.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkonstantinsimeonov%2Ffluent-schemer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkonstantinsimeonov%2Ffluent-schemer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkonstantinsimeonov%2Ffluent-schemer/lists"}