Skip to content

validate models before using them in your Tradle bots

Notifications You must be signed in to change notification settings

tradle/validate-model

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@tradle/validate

validate your Tradle models

Usage

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)