{"id":15233398,"url":"https://github.com/ajv-validator/ajv-pack","last_synced_at":"2025-10-04T18:31:32.929Z","repository":{"id":55920632,"uuid":"68957935","full_name":"ajv-validator/ajv-pack","owner":"ajv-validator","description":"🚨[ARCHIVED] Produces a compact module exporting JSON-schema validation functions compiled by Ajv","archived":true,"fork":false,"pushed_at":"2020-12-13T15:29:22.000Z","size":41,"stargazers_count":43,"open_issues_count":14,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-08-28T04:33:33.034Z","etag":null,"topics":["ajv","compiler","json-schema","validator"],"latest_commit_sha":null,"homepage":"https://ajv.js.org","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/ajv-validator.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-22T20:05:01.000Z","updated_at":"2024-05-17T16:45:12.000Z","dependencies_parsed_at":"2022-08-15T09:30:49.185Z","dependency_job_id":null,"html_url":"https://github.com/ajv-validator/ajv-pack","commit_stats":null,"previous_names":["epoberezkin/ajv-pack"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/ajv-validator/ajv-pack","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajv-validator%2Fajv-pack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajv-validator%2Fajv-pack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajv-validator%2Fajv-pack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajv-validator%2Fajv-pack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ajv-validator","download_url":"https://codeload.github.com/ajv-validator/ajv-pack/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajv-validator%2Fajv-pack/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273208769,"owners_count":25064202,"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","status":"online","status_checked_at":"2025-09-01T02:00:09.058Z","response_time":120,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["ajv","compiler","json-schema","validator"],"created_at":"2024-09-29T05:08:29.218Z","updated_at":"2025-10-04T18:31:32.613Z","avatar_url":"https://github.com/ajv-validator.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ajv-pack\n\n## DEPRECATED / ARCHIVED\n\nPlease use [standalone validation code](https://github.com/ajv-validator/ajv/blob/master/docs/standalone.md) module included in Ajv v7.\n\nProduces a compact module exporting JSON-schema validation functions compiled by [Ajv](https://github.com/epoberezkin/ajv)\n\n[![Build Status](https://travis-ci.org/epoberezkin/ajv-pack.svg?branch=master)](https://travis-ci.org/epoberezkin/ajv-pack)\n[![npm version](https://badge.fury.io/js/ajv-pack.svg)](https://www.npmjs.com/package/ajv-pack)\n[![Coverage Status](https://coveralls.io/repos/github/epoberezkin/ajv-pack/badge.svg?branch=master)](https://coveralls.io/github/epoberezkin/ajv-pack?branch=master)\n\n\n## Purpose\n\nThis package allows to create standalone modules for validation functions that are pre-compiled and can be used without Ajv. It can be necessary for several reasons:\n\n- to reduce the browser bundle size - Ajv is not included in the bundle (although if you have a large number of schemas the bundle can become bigger - when the total size of generated validation code is bigger than Ajv code).\n- to reduce the startup time - the validation and compilation of schemas will happen during build time.\n- to avoid dynamic code evaluation with Function constructor (used for schema compilation) - it can be prohibited in case [Content Security Policy](http://www.html5rocks.com/en/tutorials/security/content-security-policy/) is used.\n\n__Please note__: there are many cases when Ajv works as expected and ajv-pack does not. Some of these cases are listed in [Limitations](#limitations). It is recommended to test schemas compiled with this package more thoroughly than you would when using Ajv (which is very stable and well tested). Please submit issues with cases that fail.\n\n\n## Usage with CLI\n\nIn most cases you would use this package via [ajv-cli](https://github.com/jessedc/ajv-cli) (\u003e= 1.0.0) to generate module that exports validation function.\n\n```sh\nnpm install -g ajv-cli\najv compile -s schema.json -o validate_schema.js\n```\n\n`validate_schema.js` will contain the module exporting validation function that can be bundled into your application.\n\n\n## Usage from code\n\n```sh\nnpm install ajv-pack\n```\n\n```javascript\nvar Ajv = require('ajv'); // version \u003e= 4.7.4\nvar ajv = new Ajv({sourceCode: true}); // this option is required\nvar pack = require('ajv-pack');\n\nvar schema = {\n  type: 'object',\n  properties: {\n    foo: {\n      type: 'string',\n      pattern: '^[a-z]+$'\n    }\n  }\n};\n\nvar validate = ajv.compile(schema);\nvar moduleCode = pack(ajv, validate);\n\n// now you can\n// 1. write module code to file\nvar fs = require('fs');\nvar path = require('path');\nfs.writeFileSync(path.join(__dirname, '/validate.js'), moduleCode);\n\n// 2. require module from string\nvar requireFromString = require('require-from-string');\nvar packedValidate = requireFromString(moduleCode);\n```\n\nAjv should still be a run-time dependency, but generated modules will only depend on some parts of it, the whole Ajv will not be included in the bundle if you require these modules from your code.\n\n\n## Limitations\n\nAt the moment ajv-pack does not support schemas with:\n\n- custom 'compiled' and 'validated' keywords; custom inline and macro keywords are supported.\n- custom formats (they will be ignored during validation).\n- recursive references (reference to the current schema `{ \"$ref\": \"#\" }` is supported).\n- asynchronous schemas (they require custom keywords/formats).\n\n\n## License\n\n[MIT](https://github.com/epoberezkin/ajv-pack/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajv-validator%2Fajv-pack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fajv-validator%2Fajv-pack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajv-validator%2Fajv-pack/lists"}