Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tradle/validate-model

validate models before using them in your Tradle bots
https://github.com/tradle/validate-model

data-modeling modeling tradle validation

Last synced: about 2 months ago
JSON representation

validate models before using them in your Tradle bots

Awesome Lists containing this project

README

        

# @tradle/validate

validate your Tradle models

## Usage

```js
const baseModels = require('@tradle/models').models
const validate = require('@tradle/validate-model')
const nameModel = {
type: 'tradle.Model',
id: 'com.example.Name',
title: 'Name',
properties: {
fullName: {
type: 'string'
},
nickName: {
type: 'string'
}
},
required: ['nickName']
}

// validate a property
validate.property({ model: nameModel, propertyName: 'nickName' })

// validate a model
validate.model(nameModel)

// validate all models and their cross-references
const mergedModels = Object.assign({}, baseModels, { [nameModel.id]: nameModel })
validate(mergedModels)
```