{"id":13989693,"url":"https://github.com/diegohaz/schm","last_synced_at":"2025-05-16T14:06:14.076Z","repository":{"id":21695021,"uuid":"93794656","full_name":"diegohaz/schm","owner":"diegohaz","description":"Composable schemas for JavaScript and Node.js","archived":false,"fork":false,"pushed_at":"2022-12-08T18:52:21.000Z","size":1391,"stargazers_count":512,"open_issues_count":38,"forks_count":23,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-03T11:36:56.053Z","etag":null,"topics":["compose","functional-programming","joi","json-schema","lerna","parse","schema","validate"],"latest_commit_sha":null,"homepage":"https://git.io/schm","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/diegohaz.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-06-08T21:49:44.000Z","updated_at":"2025-04-03T11:17:37.000Z","dependencies_parsed_at":"2023-01-12T03:45:52.668Z","dependency_job_id":null,"html_url":"https://github.com/diegohaz/schm","commit_stats":null,"previous_names":[],"tags_count":77,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diegohaz%2Fschm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diegohaz%2Fschm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diegohaz%2Fschm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diegohaz%2Fschm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/diegohaz","download_url":"https://codeload.github.com/diegohaz/schm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254112135,"owners_count":22016699,"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":["compose","functional-programming","joi","json-schema","lerna","parse","schema","validate"],"created_at":"2024-08-09T13:01:57.790Z","updated_at":"2025-05-16T14:06:14.025Z","avatar_url":"https://github.com/diegohaz.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","functional-programming","📦 Legacy \u0026 Inactive Projects"],"sub_categories":[],"readme":"# \u003cimg src=\"logo/logo.svg\" width=\"200\"\u003e\n\n[![Build Status](https://img.shields.io/travis/diegohaz/schm/master.svg?style=flat-square)](https://travis-ci.org/diegohaz/schm) [![Coverage Status](https://img.shields.io/codecov/c/github/diegohaz/schm/master.svg?style=flat-square)](https://codecov.io/gh/diegohaz/schm/branch/master)\n\n- [**Introductory article**](https://medium.freecodecamp.org/how-to-write-powerful-schemas-in-javascript-490da6233d37)\n- [**Main documentation**](packages/schm#readme)\n- [**Examples**](https://runkit.com/diegohaz/schm)\n\n\u003cbr\u003e\n\u003chr\u003e\n\u003cp align=\"center\"\u003e\nIf you find this useful, please don't forget to star ⭐️ the repo, as this will help to promote the project.\u003cbr\u003e\nFollow me on \u003ca href=\"https://twitter.com/diegohaz\"\u003eTwitter\u003c/a\u003e and \u003ca href=\"https://github.com/diegohaz\"\u003eGitHub\u003c/a\u003e to keep updated about this project and \u003ca href=\"https://github.com/diegohaz?tab=repositories\"\u003eothers\u003c/a\u003e.\n\u003c/p\u003e\n\u003chr\u003e\n\u003cbr\u003e\u003cbr\u003e\n\n**schm** is a library for creating immutable, composable, parseable and validatable (yeah, many *ables) schemas in JavaScript and Node.js. That's highly inspired by [functional programming](https://en.wikipedia.org/wiki/Functional_programming) paradigm.\n\nPlay with `schm` on [RunKit](https://runkit.com/diegohaz/schm) (click on *Clone and edit this document* at the bottom and skip login if you want).\n\n```js\nconst schema = require('schm')\n\nconst userSchema = schema({\n  name: String,\n  age: {\n    type: Number,\n    min: 18,\n  },\n})\n\nuserSchema.parse({\n  name: 'Haz',\n  age: '27',\n})\n\nawait userSchema.validate({\n  name: 'Jeane',\n  age: 10,\n})\n```\n\nOutput:\n```js\n// parsed\n{\n  name: 'Haz',\n  age: 27,\n}\n\n// validate error\n[\n  {\n    param: 'age',\n    value: 10,\n    validator: 'min',\n    min: 18,\n    message: 'age must be greater than or equal 18',\n  },\n]\n```\n\nThe way you declare the schema object is very similar to [mongoose Schemas](http://mongoosejs.com/docs/guide.html). So, refer to their docs to learn more.\n\n## Packages\n\n`schm` repository is a [monorepo](https://danluu.com/monorepo/) managed by [lerna](https://github.com/lerna/lerna). Click on package name to see specific **documentation**.\n\n| Package | Version | Description |\n|---|---|---|\n| [`schm`](packages/schm) | [![NPM version](https://img.shields.io/npm/v/schm.svg?style=flat-square)](https://npmjs.org/package/schm) | The main package |\n| [`schm-computed`](packages/schm-computed) | [![NPM version](https://img.shields.io/npm/v/schm-computed.svg?style=flat-square)](https://npmjs.org/package/schm-computed) | Adds computed parameters to schemas |\n| [`schm-express`](packages/schm-express) | [![NPM version](https://img.shields.io/npm/v/schm-express.svg?style=flat-square)](https://npmjs.org/package/schm-express) | Express middlewares to handle querystring and response body |\n| [`schm-koa`](packages/schm-koa) | [![NPM version](https://img.shields.io/npm/v/schm-koa.svg?style=flat-square)](https://npmjs.org/package/schm-koa) | Koa middlewares to handle querystring and response body |\n| [`schm-methods`](packages/schm-methods) | [![NPM version](https://img.shields.io/npm/v/schm-methods.svg?style=flat-square)](https://npmjs.org/package/schm-methods) | Adds methods to parsed schema objects |\n| [`schm-mongo`](packages/schm-mongo) | [![NPM version](https://img.shields.io/npm/v/schm-mongo.svg?style=flat-square)](https://npmjs.org/package/schm-mongo) | Parses values to MongoDB queries |\n| [`schm-translate`](packages/schm-translate) | [![NPM version](https://img.shields.io/npm/v/schm-translate.svg?style=flat-square)](https://npmjs.org/package/schm-translate) | Translates values keys to schema keys |\n\n## Contributing\n\nWhen submitting an issue, put the related package between brackets in the title:\n\n```sh\n[methods] Something wrong is not right # related to schm-methods\n[translate] Something right is not wrong # related to schm-translate\nSomething wrong is wrong # general issue\n```\n\nPRs are welcome. You should have a look at [lerna](https://github.com/lerna/lerna) to understand how this repository works.\n\nAfter cloning the repository, run `yarn`. That will install all the project dependencies, including the packages ones.\n\nBefore submitting a PR:\n\n1. Make sure to lint the code: `yarn lint` or `lerna run lint`;\n2. Make sure tests are passing: `yarn test` or `lerna run test`;\n\n## License\n\nMIT © [Diego Haz](https://github.com/diegohaz)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiegohaz%2Fschm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdiegohaz%2Fschm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiegohaz%2Fschm/lists"}