{"id":22645522,"url":"https://github.com/akmjenkins/schema2","last_synced_at":"2026-04-25T16:33:25.979Z","repository":{"id":47247070,"uuid":"342594643","full_name":"akmjenkins/schema2","owner":"akmjenkins","description":"serializable validation and logic rules","archived":false,"fork":false,"pushed_at":"2021-09-07T02:00:24.000Z","size":844,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-03T18:15:30.593Z","etag":null,"topics":["json-schema","validation"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/akmjenkins.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-26T14:08:03.000Z","updated_at":"2021-09-07T02:00:26.000Z","dependencies_parsed_at":"2022-09-22T11:30:29.427Z","dependency_job_id":null,"html_url":"https://github.com/akmjenkins/schema2","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/akmjenkins%2Fschema2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akmjenkins%2Fschema2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akmjenkins%2Fschema2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akmjenkins%2Fschema2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akmjenkins","download_url":"https://codeload.github.com/akmjenkins/schema2/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246145603,"owners_count":20730593,"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":["json-schema","validation"],"created_at":"2024-12-09T06:06:16.171Z","updated_at":"2026-04-25T16:33:25.950Z","avatar_url":"https://github.com/akmjenkins.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Schema3\n\n[![npm version](https://img.shields.io/npm/v//schema2.svg)](https://npmjs.org/package/schema2)\n[![Coverage Status](https://coveralls.io/repos/github/akmjenkins/schema2/badge.svg)](https://coveralls.io/github/akmjenkins/schema2)\n![Build Status](https://github.com/akmjenkins/schema2/actions/workflows/main.yaml/badge.svg)\n[![Bundle Phobia](https://badgen.net/bundlephobia/minzip/schema2)](https://bundlephobia.com/result?p=schema2)\n\nImagining a future JSON schema.\n\n## Why?\n\nMainly because JSON schema's syntax is inconsistent. Every draft there are new keywords being added, and it's hard to keep track of them all. Schema2 built upon the [@zuze-lab/schema](https://github.com/zuze-lab/schema) but got rid of the functional flavor while keeping the abstract syntax tree.\n\nPopular validators like [ajv](https://github.com/ajv-validator/ajv) or [hyperjump](https://github.com/hyperjump-io/json-schema-validator) are undoubtedly powerful, but, having evolved with JSON schema, have lots of complex configuration options, inconsistent syntax, and have [become](https://bundlephobia.com/result?p=@hyperjump/json-schema) [bloated](https://bundlephobia.com/result?p=ajv).\n\n`schema2`, at it's core, is only about 2kb minzipped and under 7kb minzipped for all 7 schemas (mixed, number, boolean, string, date, object, array) including all 24 transformation operators and all 35 test operators.\n\n## Keywords\n\nThe only keywords you need to know about for _Schema2_ are:\n\n- `type` - specifies the type of schema\n- `label` - a label, helpful, for error messages\n- `tests` - all the validations that you want to do (this is where all the keywords go)\n- `transforms` - ability to transform values\n- `typeError` - ability to specify an error message for invalid type during validation\n- `inner` - the inner schema definition for objects and arrays/tuples\n- `conditions` - the ability to modify the validations or transforms of any schema depending on the value being validated or external [context](#context)\n- `nullable` - null and undefined are treated as special values. Tests **WILL NOT** be run on null and undefined values. A special `nonNullable` error will be returned for a given schema if null is received as a value for a schema where `nullable` is false\n\n###\n\nThese are the list of validators shipped with `schema2`:\n\n### Example\n\n```json\n{\n  \"type\": \"object\",\n  \"label\": \"user\",\n  \"inner\": {\n    \"firstName\": {\n      \"type\": \"string\"\n    },\n    \"lastName\": {\n      \"type\": \"string\"\n    }\n  },\n  \"tests\": [\n    {\n      \"name\": \"keys\",\n      \"schema\": {\n        \"type\": \"string\",\n        \"tests\": [\n          {\n            \"type\": \"oneOf\",\n            \"values\": [\"firstName\", \"lastName\"]\n          }\n        ]\n      }\n    }\n  ],\n  \"conditions\": [\n    {\n      \"when\": {\n        \"user.firstName\": {\n          \"tests\": [{ \"type\": \"required\" }]\n        }\n      },\n      \"then\": {\n        \"inner\": {\n          \"lastName\": {\n            \"tests\": [{ \"type\": \"required\" }]\n          }\n        }\n      }\n    }\n  ]\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakmjenkins%2Fschema2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakmjenkins%2Fschema2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakmjenkins%2Fschema2/lists"}