2.2.7 • Published 1 month ago

@manuscripts/json-schema v2.2.7

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
1 month 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.7

1 month ago

2.2.6

2 months ago

2.2.5-LEAN-3376-0

2 months ago

2.2.5

2 months ago

2.2.4-LEAN-3376-1

2 months ago

2.2.4-LEAN-3376-0

2 months ago

2.2.4-LEAN-3092-0

2 months ago

2.2.4-LEAN-3092-1

2 months ago

2.2.4

2 months ago

2.2.3-LEAN-3376-2

2 months ago

2.2.4-LEAN-3377-0

2 months ago

2.2.3-LEAN-3377-1

2 months ago

2.2.3-LEAN-3377-0

2 months ago

2.2.3-LEAN-3376-1

2 months ago

2.2.3-LEAN-3376-0

2 months ago

2.2.3

3 months ago

2.2.3-LEAN-3092-0

3 months ago

2.2.3-LEAN-3092-1

3 months ago

2.2.2-LEAN-3366-0

3 months ago

2.2.2-LEAN-3094-0

3 months ago

2.2.2-LEAN-3094-1

3 months ago

2.2.2-LEAN-3094

3 months ago

2.2.2-LEAN-3093

4 months ago

2.2.2-LEAN-3092

4 months ago

2.2.2

4 months ago

2.2.1-LEAN-3092-v2

4 months ago

2.2.1-LEAN-3092-v1

4 months ago

2.2.1-LEAN-3092

4 months ago

2.2.1-LEAN-3034

5 months ago

2.2.1

5 months ago

2.2.0-LEAN-2852-13

5 months ago

2.2.0-LEAN-2852-14

5 months ago

2.2.0-LEAN-2852-7

6 months ago

2.2.0-LEAN-2852-5

6 months ago

2.2.0-LEAN-2852-4

6 months ago

2.2.0-LEAN-2852-3

6 months ago

2.2.0-LEAN-2853

7 months ago

2.2.0-LEAN-2852-2

7 months ago

2.2.0-LEAN-2852-1

7 months ago

2.2.0-LEAN-2852-0

7 months ago

2.2.0-LEAN-2852

7 months ago

2.1.2

8 months ago

2.0.3

10 months ago

2.2.0

8 months ago

2.1.1

9 months ago

2.0.4

10 months ago

2.1.1-LEAN-2715-4

8 months ago

2.1.1-LEAN-2715-3

8 months ago

2.1.0

10 months ago

2.1.1-LEAN-2715-1

8 months ago

2.1.1-LEAN-2712

9 months ago

2.0.2-LEAN-2501

10 months ago

2.2.0-LEAN-2852-10

6 months ago

2.1.1-LEAN-2715-v5

8 months ago

2.1.1-LEAN-2715-v6

8 months ago

2.2.0-LEAN-2852-12

6 months ago

2.0.2-LEAN-2501-v2

10 months ago

2.2.0-LEAN-2852-8

6 months ago

2.1.1-LEAN-2715-v1

9 months ago

2.1.1-LEAN-2715-v2

8 months ago

2.1.1-LEAN-2715-v3

8 months ago

2.0.2

11 months ago

2.0.2-LEAN-2553

11 months ago

2.0.1-LEAN-2416

12 months ago

2.0.1

12 months ago

2.0.0

1 year ago

1.1.0

1 year ago

1.0.0

1 year ago