{"id":23009884,"url":"https://github.com/openactive/data-model-validator","last_synced_at":"2025-08-14T04:33:05.217Z","repository":{"id":33153254,"uuid":"140412448","full_name":"openactive/data-model-validator","owner":"openactive","description":"The OpenActive data model validator library","archived":false,"fork":false,"pushed_at":"2024-08-06T18:44:53.000Z","size":1123,"stargazers_count":1,"open_issues_count":92,"forks_count":1,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-12-08T16:16:02.285Z","etag":null,"topics":["validators"],"latest_commit_sha":null,"homepage":null,"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/openactive.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-10T09:56:09.000Z","updated_at":"2024-06-21T13:47:49.000Z","dependencies_parsed_at":"2024-03-28T10:35:52.794Z","dependency_job_id":"07ea8413-3a29-46f6-874b-dcaf0f0aeae2","html_url":"https://github.com/openactive/data-model-validator","commit_stats":{"total_commits":444,"total_committers":11,"mean_commits":40.36363636363637,"dds":0.4864864864864865,"last_synced_commit":"5c46a00971dfe16e7221680b89ff1a6a287f0290"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openactive%2Fdata-model-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openactive%2Fdata-model-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openactive%2Fdata-model-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openactive%2Fdata-model-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/openactive","download_url":"https://codeload.github.com/openactive/data-model-validator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229800368,"owners_count":18126028,"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":["validators"],"created_at":"2024-12-15T09:16:21.622Z","updated_at":"2024-12-15T09:16:22.259Z","avatar_url":"https://github.com/openactive.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenActive Data Model Validator\n\nThe OpenActive data model validator library.\n\n[![Tests](https://github.com/openactive/data-model-validator/actions/workflows/npm-test.yml/badge.svg?branch=master)](https://github.com/openactive/data-model-validator/actions/workflows/npm-test.yml)\n[![Known Vulnerabilities](https://snyk.io/test/github/openactive/data-model-validator/badge.svg)](https://snyk.io/test/github/openactive/data-model-validator)\n\n## Introduction\n\nThis library allows developers to validate JSON models to the latest [OpenActive Modelling Opportunity Data](https://openactive.io/modelling-opportunity-data/) specification.\n\n## Using in your application\n\nThis library can be used in your own application, perhaps as part of your CI pipeline.\n\n### Install\n\n```shell\n$ npm install @openactive/data-model-validator\n```\n\n### Usage\n\n```js\nconst { validate } = require('@openactive/data-model-validator');\n\nconst data = {\n  '@context': 'https://openactive.io/',\n  '@type': 'Event',\n  name: 'Tai chi Class',\n  url: 'http://www.example.org/events/1',\n  startDate: '2017-03-22T20:00:00',\n  activity: 'Tai Chi',\n  location: {\n    '@type': 'Place',\n    name: 'ExampleCo Gym',\n    address: {\n      '@type': 'PostalAddress',\n      streetAddress: '1 High Street',\n      addressLocality: 'Bristol',\n      postalCode: 'BS1 4SD'\n    }\n  }\n};\n\n// Check whether the JSON conforms to the Event model\nconst result = await validate(data);\n\n// Returns:\n// [{category: 'conformance', type: 'missing_required_field', message: 'Required field is missing.', value: undefined, severity: 'failure', path: '$.context' }, ... ]\n```\n\n### Options\n\nThe `validate` method optionally accepts options for validation:\n\n#### loadRemoteJson\n\n**Default:** `false`\n\nWhether to load remote JSON documents. For example, remote `@context` definitions or activity list definitions.\n\ne.g.\n\n```js\nconst { validate } = require('@openactive/data-model-validator');\n\nconst data = {\n// ...\n};\n\nconst options = {\nloadRemoteJson: true\n};\n\nconst result = await validate(data, options);\n```\n\n#### remoteJsonCachePath\n\n**Default:** `null`\n\nUsed in conjunction with `loadRemoteJson`. If set, allows the JSON loader to cache requests.\n\ne.g.\n\n```js\nconst { validate } = require('@openactive/data-model-validator');\n\nconst data = {\n// ...\n};\n\nconst options = {\nloadRemoteJson: true,\nremoteJsonCachePath: '/tmp'\n};\n\nconst result = await validate(data, options);\n```\n\n#### remoteJsonCacheTimeToLive\n\n**Default:** `3600`\n\nUsed in conjunction with `loadRemoteJson` and `remoteJsonCachePath`. It sets the number of seconds that the JSON loader should cache requests for.\n\ne.g.\n\n```js\nconst { validate } = require('@openactive/data-model-validator');\n\nconst data = {\n// ...\n};\n\nconst options = {\n  loadRemoteJson: true,\n  remoteJsonCachePath: '/tmp',\n  remoteJsonCacheTimeToLive: 3600\n};\n\nconst result = await validate(data, options);\n```\n\n#### rpdeItemLimit\n\nA limit of the number of RPDE `\"updated\"` data items to validate. It is helpful to limit the number of items validated for performance reasons.\n\ne.g.\n\n```js\nconst { validate } = require('@openactive/data-model-validator');\n\nconst feed = {\n// ...\n};\n\nconst options = {\n  rpdeItemLimit: 10\n};\n\nconst result = await validate(feed, options);\n```\n\n\n#### type\n\nThe validator will detect the type of the model being validated from the `@type` property. You can override this by providing a `type` option.\n\ne.g.\n\n```js\nconst { validate } = require('@openactive/data-model-validator');\n\nconst model = {\n  type: 'CustomAction'\n  // ...\n};\n\nconst options = {\n  type: 'Action'\n};\n\nconst result = await validate(model, options);\n```\n\n#### version\n\nThe version of the specification to validate against. If not provided, this will validate against the latest specification.\n\ne.g.\n\n```js\nconst { validate } = require('@openactive/data-model-validator');\n\nconst model = {\n  type: 'CustomAction'\n  // ...\n};\n\nconst options = {\n  version: '2.0'\n};\n\nconst result = await validate(model, options);\n}\n```\n\n#### validationMode\n\nProvides context as to how the data under validation is expected to be used and therefore some validation rules may or may not apply.\nFor example, OrderQuotes only have a customer attribute in the C2 phase and beyond of booking (so not in C1Request or C1Response nor any more generic published open data usage).\n\ne.g. To only apply rules that are suitable for data used in a booking flow phase like C2Request:\n\n```js\nconst { validate, ValidationMode } = require('@openactive/data-model-validator');\n\nconst model = {\n  type: 'CustomAction'\n  // ...\n};\n\nconst options = {\n  validationMode: 'C2Request'\n  // ...\n};\n\nconst result = validate(model, options);\n```\n\n## Development\n\n### Getting started\n\n```shell\n$ git clone git@github.com:openactive/data-model-validator.git\n$ cd data-model-validator\n$ npm install\n```\n### Running tests\n\nThis project uses [Jasmine](https://jasmine.github.io/) for its tests. All spec files are located alongside the files that they target.\n\nTo run tests locally, run:\n\n```shell\n$ npm test\n```\n\nThe test run will also include a run of [eslint](https://eslint.org/) and [TypeScript](https://www.typescriptlang.org/). To run the tests without these, use:\n\n```shell\n$ npm run run-tests\n```\n\n### Contributing\n\nRead the [Contributing Guide](./CONTRIBUTING.md) for information on how to write your own rules.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenactive%2Fdata-model-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenactive%2Fdata-model-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenactive%2Fdata-model-validator/lists"}