@bluehalo/fhir-json-schema-validator

0.11.0 • Public • Published

FHIR-JSON-SCHEMA-VALIDATOR

Utility for validating FHIR resources

Install

yarn add @bluehalo/fhir-json-schema-validator

Arguments

@bluehalo/fhir-json-schema-validator exports a single class called JSONSchemaValidator. This class takes two optional arguments for initialization:

schema

This is the path to the JSON schema that you would like to validate against. It defaults to the fhir.schema.json file included in this package.

ajvSettings

This is an object with the settings to pass on to AJV. It defaults to suppresses log and warn messages, but logs error messages. For a full list of AJV options see the README on the AJV GitHub page athttps://github.com/epoberezkin/ajv.

// Default initialization:
let defaultValidator = new JSONSchemaValidator();

// Custom initialization
let defaultValidator = new JSONSchemaValidator(schema, ajvSettings);

Usage

The QueryBuilder class has a method called validate which takes two arguments:

resource

The resource that is to be validated against the FHIR JSON schema.

verbose

Boolean value specifying whether or not to return the full set of validation errors (true) or to take the time to condense error messages (false). Defaults to false. The error messages generated by the over-arching json schema are too numerous to be of any use. For any specific resource, we can compile a resource-specific validator and re-validate to get more concise and helpful error messages.

The validate method returns an array that contains any errors generated from validation. This list will be of length 0 if no errors were found.

See index.test.js for examples of usage

Readme

Keywords

none

Package Sidebar

Install

npm i @bluehalo/fhir-json-schema-validator

Weekly Downloads

4

Version

0.11.0

License

MIT

Unpacked Size

3.38 MB

Total Files

7

Last publish

Collaborators

  • ekdeveloper
  • shane-bh
  • ashin-bluehalo
  • reblace