{"id":13630653,"url":"https://github.com/kaelzhang/skema","last_synced_at":"2025-04-13T05:05:16.641Z","repository":{"id":19325198,"uuid":"22563615","full_name":"kaelzhang/skema","owner":"kaelzhang","description":"🛰  Skema provides a handy \u0026 composable way to validate / transform / purify the input data.","archived":false,"fork":false,"pushed_at":"2020-05-05T15:07:44.000Z","size":277,"stargazers_count":356,"open_issues_count":4,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-13T05:04:39.162Z","etag":null,"topics":["model","schema","setter","skema","struct","structure","validation"],"latest_commit_sha":null,"homepage":"https://npm.im/skema","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kaelzhang.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.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":"2014-08-03T01:29:51.000Z","updated_at":"2024-05-20T11:09:30.000Z","dependencies_parsed_at":"2022-09-09T10:21:18.847Z","dependency_job_id":null,"html_url":"https://github.com/kaelzhang/skema","commit_stats":null,"previous_names":[],"tags_count":95,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaelzhang%2Fskema","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaelzhang%2Fskema/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaelzhang%2Fskema/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaelzhang%2Fskema/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kaelzhang","download_url":"https://codeload.github.com/kaelzhang/skema/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248665748,"owners_count":21142123,"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":["model","schema","setter","skema","struct","structure","validation"],"created_at":"2024-08-01T22:01:52.532Z","updated_at":"2025-04-13T05:05:16.619Z","avatar_url":"https://github.com/kaelzhang.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","📦 Legacy \u0026 Inactive Projects"],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/kaelzhang/skema.svg?branch=master)](https://travis-ci.org/kaelzhang/skema)\n[![Coverage](https://codecov.io/gh/kaelzhang/skema/branch/master/graph/badge.svg)](https://codecov.io/gh/kaelzhang/skema)\n\n# skema\n\n`skema` provides a handy and composable way to validate/transform JavaScript variables:\n\n- **Supports both async and sync flows.** Skema has two working modes to support either async or sync validators, setters, etc, making it capable with much more complicated challenges.\n\n- **NOT only type checker.** Unlike [TypeScript](https://www.typescriptlang.org/), [joi](https://github.com/hapijs/joi), and many others, Skema is not only a JavaScript type checker, but also a good solution for your [Anti-Corruption Layer (ACL)](https://docs.microsoft.com/en-us/azure/architecture/patterns/anti-corruption-layer) to transform and purify the input data. And Skema could also be configured as a simple schema validator too.\n\n- **Pluggable basic types.** Even basic types such as `Number` could also be replaced and customized if using Skema. Actually, in the core of Skema, there is NOT a single definition of one type.\n\n- **Powerful custom types.** Every single type is able to be customized that you can handle almost everything including descriptor, conditions, default values, validators and so on.\n\n- **Composable structures.** You could build a much bigger schema with the small ones into the whole world.\n\n## Install\n\n```sh\nnpm i skema\n```\n\n## Basic Usage\n\n[🔬 Live Demo with JsFiddle](https://jsfiddle.net/kaelzhang/0r3g4ogj/)\n\n```js\nimport {shape} from 'skema'\n\n// Schema definitions are ONLY objects.\nconst User = shape({\n  id: 'number?',\n  name: String\n})\n\n// Then use these definitions to purify our data.\nconst user = User.from({\n  id: '1',\n  name: 'Steve'\n})\n\nconsole.log(user)\n// {\n//   id: 1,\n//   name: 'Steve'\n// }\n\nuser.id = 'boooom!'\n// throw TypeError\n// - message: 'not a number'\n// - code: 'VALIDATION_FAILS'\n```\n\n## Documentations\n\n- API References\n  - [APIs](./doc/apis.md)\n  - [Builtin Types and How to Change Them](./doc/builtins.md)\n- [Shape Definition](./doc/shape.md)\n- [Working Mode: Sync or Async](./doc/working-mode.md)\n- [Assign a Property after `from()`](./doc/assign.md)\n- [Error Handling](./doc/errors.md)\n- [Contributing](./doc/contributing.md)\n\n## Many Examples\n\n- **Shape Definition**\n  - [Purify an Object Against a Shape🔬](https://jsfiddle.net/kaelzhang/0wosjdo9/)\n  - [Default Value of a Property🔬](https://jsfiddle.net/kaelzhang/zhu8crde/)\n  - [Optional Properties🔬](https://jsfiddle.net/kaelzhang/pesgkw9c/)\n  - [Skip Processing a Property🔬](https://jsfiddle.net/kaelzhang/joq5vdd7/)\n  - [Properties Descriptors: Non-Enumerable Properties, ...🔬](https://jsfiddle.net/kaelzhang/yhj2xj72/)\n- **Type Definition**\n  - [Basic Validation](./examples/basic-validation.js) | [Live Demo🔬 ](https://jsfiddle.net/kaelzhang/2au1on62/)\n  - [Async Validation](./examples/async-validation.js) | [Live Demo🔬](https://jsfiddle.net/kaelzhang/1rr5asyb/)\n  - [Multiple Validators](./examples/multiple-validators.js)\n  - [Basic Usage of Setters](./examples/setters.js)\n  - [Inherit Another Type](./examples/type-inheritance.js)\n  - [Declare a Type Alias to Make a Shortcut (Live Demo🔬)](https://jsfiddle.net/kaelzhang/7d5u4z0s/)\n  - [Use Skema as the Strict Type Checker](./examples/strict-basics.js) | [Live Demo🔬](https://jsfiddle.net/kaelzhang/14y4s0e9/)\n- [Errors🔬](https://jsfiddle.net/kaelzhang/scvLn8Ly/)\n\n## Related Packages\n\n- [@skema/basic](https://www.npmjs.com/package/@skema/basic) The default built-in javascript types of skema.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaelzhang%2Fskema","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkaelzhang%2Fskema","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaelzhang%2Fskema/lists"}