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.0.0.tar.gz (70.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-38.0.0-py3-none-any.whl (117.2 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for hestia_earth_schema_validation-38.0.0.tar.gz
Algorithm Hash digest
SHA256 f040d28af03144484ba7971099ed85795e118a7221d96d143c94e580093d2249
MD5 99328f29da44b1397e82fa9add7f2374
BLAKE2b-256 5b4d618866df08b1a5af44cf73bccb8c8a03978e4403c386e1ae99b03e2c8721

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hestia_earth_schema_validation-38.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4a301fb423a24da5c9c2f44ab1369bfd462f80b14a782cafed5712d816084f8d
MD5 88f37ff4ad49449efc39a62b5f1c63e8
BLAKE2b-256 a7d4a2cc1f1ed4ab825f28c06a3a3da6ce9fe1f51c814b516342fda5da1d0ff9

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