Skip to main content

HESTIA Schema Validation library

Project description

HESTIA Schema Validation

Module to validate data using the HESTIA Schema and Ajv.

Install

npm install @hestia-earth/schema @hestia-earth/schema-validation

Example validating JSON

const { SchemaType } = require('@hestia-earth/schema');
const { validator } = require('@hestia-earth/schema-validation/validate');

// Set to `true` to validate existing Nodes (@type/@id) or `false` for Nodes to upload (type/id)
const strictMode = false;
// Initialise the validation function, do this only once
const schemaValidation = validator(undefined, strictMode);

const node = {
  type: SchemaType.Cycle,
  id: 'my first cycle'
};

(async () => {
  const { success, errors } = await schemaValidation(node);
  console.log(success);
  // list of errors in Ajv formatting. See https://github.com/ajv-validator/ajv/tree/v6.12.6#validation-errors
  console.log(errors);
})();

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hestia_earth_schema_validation-36.2.1.tar.gz (69.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hestia_earth_schema_validation-36.2.1-py3-none-any.whl (116.2 kB view details)

Uploaded Python 3

File details

Details for the file hestia_earth_schema_validation-36.2.1.tar.gz.

File metadata

File hashes

Hashes for hestia_earth_schema_validation-36.2.1.tar.gz
Algorithm Hash digest
SHA256 e93ded2608549e5592cbb6fd51e1b09378cd132693a8742ced9b1de3b53ad9da
MD5 2597ecd92c072d854dd19aded8f3b33b
BLAKE2b-256 a0ce80b1c4b7acb5efc1dbc0bed06e4b9d1c74800b0f2f19ffdee1bd8e750264

See more details on using hashes here.

File details

Details for the file hestia_earth_schema_validation-36.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for hestia_earth_schema_validation-36.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1f1a84b1d06075dd1578832904d24aa39b3082b38e8d696c2a61b2ebd43a841e
MD5 0bf74fe76f813bfdea51ca93e53d8f58
BLAKE2b-256 8c3b5ee5e45fcc46616688f5c8495b56f421025b186e5c9b26f7639396638316

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page