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-37.2.0.tar.gz (70.1 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-37.2.0-py3-none-any.whl (116.6 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for hestia_earth_schema_validation-37.2.0.tar.gz
Algorithm Hash digest
SHA256 9186705c8e0d350978bbc20fead38f25f60d59db8a6bdae92faa347cb587183b
MD5 905d24e5cc7b18f86b8602f7a2be361b
BLAKE2b-256 45d8f4748a28be6b410fcce409183e7a07e9bc87a6c65f3974d97929e8192eae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hestia_earth_schema_validation-37.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 147f99f83d68f3a5f98e13d1d5564afc8b9f92f69362bf6aa97effc596315799
MD5 f1f6284ced431817880256526307b6fb
BLAKE2b-256 648e9351b1d7d0a3127e0d1b6b491fd7203e31d73ce6cdb5dce31bc0cfab1766

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