{"id":20461036,"url":"https://github.com/ericgj/jesquema","last_synced_at":"2025-03-05T11:27:33.004Z","repository":{"id":18057054,"uuid":"21113208","full_name":"ericgj/jesquema","owner":"ericgj","description":"Modular JSON Schema validator for javascript","archived":false,"fork":false,"pushed_at":"2014-12-02T04:57:33.000Z","size":340,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-16T00:35:35.682Z","etag":null,"topics":[],"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/ericgj.png","metadata":{"files":{"readme":"Readme.md","changelog":"History.md","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":"2014-06-23T03:48:55.000Z","updated_at":"2020-05-25T23:25:59.000Z","dependencies_parsed_at":"2022-07-13T05:40:26.948Z","dependency_job_id":null,"html_url":"https://github.com/ericgj/jesquema","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericgj%2Fjesquema","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericgj%2Fjesquema/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericgj%2Fjesquema/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericgj%2Fjesquema/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ericgj","download_url":"https://codeload.github.com/ericgj/jesquema/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242017438,"owners_count":20058430,"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":[],"created_at":"2024-11-15T12:22:56.674Z","updated_at":"2025-03-05T11:27:32.986Z","avatar_url":"https://github.com/ericgj.png","language":"JavaScript","readme":"\n# jesquema\n\n  [JSON Schema][1] validator for javascript\n\n## Features\n  \n  - modular; for example, v4 of the spec is entirely implemented by plugins\n  - built-in formats for date-time, email, hostname, ipv4, ipv6, uri\n    as well as ISO8610 datetime, date, time, regex strings\n  - extensive error/assertion reporting\n  - extendable context (results) object\n  - schema flattening (i.e. list top-level schemas that the instance is valid \n    against, for extracting descriptive data about the instance).\n  \n## Installation\n\n  Install with [component(1)](http://component.io):\n\n    $ component install ericgj/jesquema\n\n  _npm install coming soon_\n\n## Example\n\n  ```js\n  var validator = require('jesquema');\n  var v = validator('4').schema( schema );\n  \n  // simple usage, returns true or false\n  var valid = v.valid( instance );\n\n  // or to get assertion context\n  var context = v( instance );\n  if (!context.valid()) console.error( context.error() );\n  console.debug( context.trace() );\n\n  // to throw error if invalid\n  v.throw(true);\n  v.valid( instance );\n  \n  // to add custom format via regex or function\n  v.format( 'account', /^\\d{3}\\-\\d{4}$/ );\n  v.format( 'in_range', function(instance){ \n    return instance.y \u003c= (2 * instance.x); \n  });\n  \n  // to resolve remote schema refs, prefetch first and then call async\n  v.prefetch( 'http://my.schemas.com/one', \n              'http://my.schemas.com/two'\n            );\n  v.async(instance, function(err,ctx){\n    if (err) throw err;\n    var valid = ctx.valid();\n  });\n\n  // to extract links (link templates) from all valid subschemas\n  var links = v(instance).links();\n\n  ```\n\n## API\n\n## Tests\n\n  Validated against [JSON-Schema-Test-Suite][suite] as well as implementation-\n  specific tests.\n\n  To run the tests, first start the test file server (requires node.js):\n  `node test/server.js`. Make sure port 1234 is open on localhost.\n\n  Then open test/index.html in your browser (as a file, does not need to be\n  served over http).\n\n\n## TODO\n\n- document API\n- node.js compatibility\n- refactor Context\n\n\n## A note on remote references\n\n  Right now remote refs must be _prefetched_, ie. you must specify up front\n  all dependencies (including dependencies of dependencies), rather than\n  determining them from the schemas themselves. This is similar to the way\n  the [tv4][tv4] validator handles remote references.  _Dynamic_ fetching\n  (fetching based on refs encountered in the schemas themselves) is fraught\n  with complexity, and I personally do not see a compelling need for it. In\n  fact, discouraging complex graphs of dependencies between schema files\n  seems like a good idea -- wherever it can be avoided.\n\n  In a browser context, prefetching can be somewhat automated by having the\n  server specify the resources to prefetch. For instance, to stray not too\n  far from standards, the response could include [prefetch links][prefetch]\n  in a Link header:\n\n    Link: \u003c/reference1.json\u003e;rel=prefetch, \u003c/reference2.json\u003e;rel=prefetch\n\n  Then those links can be used to determine the schema files to prefetch into\n  the validator.\n\n\n## License\n\n  The MIT License (MIT)\n\n  Copyright (c) 2014 Eric Gjertsen \u003cericgj72@gmail.com\u003e\n\n  Permission is hereby granted, free of charge, to any person obtaining a copy\n  of this software and associated documentation files (the \"Software\"), to deal\n  in the Software without restriction, including without limitation the rights\n  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n  copies of the Software, and to permit persons to whom the Software is\n  furnished to do so, subject to the following conditions:\n\n  The above copyright notice and this permission notice shall be included in\n  all copies or substantial portions of the Software.\n\n  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n  THE SOFTWARE.\n\n\n[1]: http://json-schema.org/\n[suite]: https://github.com/json-schema/JSON-Schema-Test-Suite\n[tv4]: https://github.com/geraintluff/tv4\n[prefetch]: https://en.wikipedia.org/wiki/Link_prefetching\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericgj%2Fjesquema","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fericgj%2Fjesquema","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericgj%2Fjesquema/lists"}