@stremio/stremio-core-validator

2.0.2 • Public • Published

Stremio Core Validator

Build

Stremio JSON Schema Validator for Node.js using stremio-core types

Additional properties that are not part of the schema got removed. Validation functions throws error if the argument does not match the schema.

Build

npm run build

Supported types

  • Manifest
  • ManifestPreview
  • Descriptor
  • DescriptorPreview
  • MetaItem
  • MetaItemPreview
  • Stream
  • Subtitles
  • Video
  • ResourceResponse

Example

MetaItemPreview validation

meta refers to javascript object with valid MetaItemPreview schema

const validator = require('@stremio/stremio-core-validator');
const meta = validator.meta_item_preview({
    id: 'id',
    type: 'type',
    name: 'name'
});

Cathing errors

error refers to Error object with message describing which field is invalid

const validator = require('@stremio/stremio-core-validator');
try {
    const meta = validator.meta_item_preview({
        id: 'id',
        // type: 'type',
        name: 'name'
    });
} catch (error) {
    console.log(error.message);
}

Readme

Keywords

none

Package Sidebar

Install

npm i @stremio/stremio-core-validator

Weekly Downloads

1

Version

2.0.2

License

MIT

Unpacked Size

863 kB

Total Files

4

Last publish

Collaborators

  • nklhrstv
  • ivogeorgiev