2.2.11 • Published 10 months ago

@manuscripts/json-schema v2.2.11

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
10 months ago

json-schema

The Manuscripts JSON Schema types and validation functions.

Build

yarn build

Validation

To validate a document against the schema, the validate function can be used:

import { validate } from '@manuscripts/json-schema';

const document = {
    objectType: 'MPManuscript'
};

const error = validate(document);
if (!error) {
    console.log('document is valid');
} else {
    console.log(`document is invalid: ${error}`);
}

The schema is selected based on the objectType property of the document.

Types

A Typescript interface is generated (and included in the package) for each abstract/concrete schema:

import { Model } from '@manuscripts/json-schema';

function getId(document: Model) {
    return document._id;
}

An ObjectTypes enum is also available that includes all supported types with their corresponding objectType value:

import { Model, ObjectTypes } from '@manuscripts/json-schema';

function isManuscript(document: Model) {
    return document.objectType === ObjectTypes.Manuscript;
}
2.2.11

10 months ago

2.2.10

12 months ago

2.2.11-LEAN-3647.0

10 months ago

2.2.9

12 months ago

2.2.8

1 year ago

2.2.7

1 year ago

2.2.6

1 year ago

2.2.5

1 year ago

2.2.4

1 year ago

2.2.3

1 year ago

2.2.2-LEAN-3094

1 year ago

2.2.2-LEAN-3093

1 year ago

2.2.2-LEAN-3092

1 year ago

2.2.2

1 year ago

2.2.1-LEAN-3092

1 year ago

2.2.1-LEAN-3034

2 years ago

2.2.1

2 years ago

2.2.0-LEAN-2853

2 years ago

2.2.0-LEAN-2852

2 years ago

2.1.2

2 years ago

2.0.3

2 years ago

2.2.0

2 years ago

2.1.1

2 years ago

2.0.4

2 years ago

2.1.0

2 years ago

2.1.1-LEAN-2712

2 years ago

2.0.2-LEAN-2501

2 years ago

2.0.2

2 years ago

2.0.2-LEAN-2553

2 years ago

2.0.1-LEAN-2416

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago