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-38.3.0.tar.gz (70.8 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-38.3.0-py3-none-any.whl (117.5 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for hestia_earth_schema_validation-38.3.0.tar.gz
Algorithm Hash digest
SHA256 04c41f6909eeab9cd18c4d357335540d99b431da3f910ad3dc2679bffae275b3
MD5 3b5bfd4ef6a6ea6faaee2c40bd533870
BLAKE2b-256 596dd9cb33685322562c751ec98f7aa52d4db757c1c786eee98f750b0f64704b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hestia_earth_schema_validation-38.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7f96f28e5b3dc2f1344324ae7ee06dbe97565f8eb530f993fb6349bafe3a10ff
MD5 a27904c2de55fe5812b58ce7cbc80d3b
BLAKE2b-256 348f34ce1a4fecb8f77957569c521acc5eb9a106c51ad0985ea27188e9487792

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