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.1.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.1-py3-none-any.whl (116.6 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for hestia_earth_schema_validation-37.2.1.tar.gz
Algorithm Hash digest
SHA256 720db4002669e782e6cf8f2b3cde18f1ce9371562d5f454d124258b2604bfffe
MD5 9a5a7450f5e9b786e143c99c587fda30
BLAKE2b-256 86ce9ddcb7350fbfcd0d679932a6d72f4aeccb5b8a90cdfcd02c135d4e4c3c71

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hestia_earth_schema_validation-37.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fbd3a6ab063ddf87a8ade31015d6a1b94742cd822c0fab0613ac79fb5a6834ec
MD5 a10643ebc7f431cd8d81c18a2d60380c
BLAKE2b-256 93c4bafea01ce2246582b307702a3551ea76c7f1050e10fad7b41dd741478995

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