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.0.0.tar.gz (69.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-37.0.0-py3-none-any.whl (116.3 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for hestia_earth_schema_validation-37.0.0.tar.gz
Algorithm Hash digest
SHA256 0c8eca48a27d934be93d05400299e1cdbc46bd180ec9fd7a6df85994c139a457
MD5 eac57872eb650e13806acb48b524546b
BLAKE2b-256 d53211a61641a45261a9a27a12d5a49c56d1c9fb1f07ba489810d73413d3b6d3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hestia_earth_schema_validation-37.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bc9c32d041d96086594b8efadf08e826b4870581910bc020afef3544e885f943
MD5 aef277215f5da344055b4067b5eb54bd
BLAKE2b-256 3bd25fca3164e6fe5921a8ce3a0e2dc9a1936ad2d08cbc2a37f6779a03565573

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