You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ reso-certification-utils schema --help
Usage: RESO Certification Utils schema [options]
Generate a schema or validate a payload against a schema
Options:
-G, --generate Generate a schema for payload validation
-V, --validate Validate one or multiple payloads with a schema
-m, --metadataPath <string> Path to the metadata report JSON file
-o, --outputPath <string> Path tho the directory to store the generated schema. Defaults to "./"
-a, --additionalProperties Pass this flag to allow additional properties in the schema. False by default
-v, --version <string> The DD version of the metadata report
-p, --payloadPath <string> Path to the payload file OR directory/zip containing files that need to be validated
-r, --resourceName <string> Resource name to validate against. Required if --version is passed when validating.
-h, --help display help for command
Generate
$ reso-certification-utils schema -G -a
Validate
$ reso-certification-utils schema -V -p <path to payloads file, zip, or directory> -a -v 2.0 -r Property
Usage in a library
const{ getReferenceMetadata }=require('reso-certification-etl');const{ generateJsonSchema, validate, combineErrors }=require('./lib/schema');constfs=require('fs/promises');// generateconstschema=awaitgenerateJsonSchema({additionalProperties: true,metadataReportJson: getReferenceMetadata('2.0')});leterrorMap={};// validateconstpayload=JSON.parse(awaitfs.readFile('<path to payloads file>'));errorMap=validate({version: '2.0',jsonPayload: payload,
errorMap,// pass the error map back into the validate input in case of usage inside a loopjsonSchema: schema,resourceName: 'Property'});// The error map will hold the results of multiple validation so to transform it into a single error report we can use `combineErrors`consterrorReport=combineErrors(errorMap);console.log(JSON.stringify(errorReport,null,2));