SSB Schema Definitions
Standardised schema definitions for SSB messages when using is-my-json-valid.
Example Usage
const Definitions = require('ssb-schema-definitions')
const Validator = require('is-my-json-valid')
const schema = {
$schema: 'http://json-schema.org/schema#',
type: 'object',
required: ['type', 'tangles'],
properties: {
type: {
type: 'string',
pattern: '^profile/.*
API
Definitions() => Object
The definitions is a getter (function) so that you can pull it and mutate it awithout getting into trouble.
To see what definitions are available check out index.js.
You can also see examples of how to use most of the definitions in the tests/ folder.
At time of writing there's good test coverage here for fields:
contentWarning
image
mentions
tangle
tombstone
recps (box1, box2/ envelope)
},
preferredName: { type: 'string' },
avatarImage: { $ref: '#/definitions/image' }, // << reference a definition
tangles: {
group: { $ref: '#/definitions/tangle/any' },
profile: { $ref: '#/definitions/tangle/root' }
},
recps: { $ref: '#/definitions/recipients/box2' }
},
additionalProperties: false,
definitions: Definitions() // attach the definitions
}
const isValid = Validator(schema)
// isValid(msgContent) => Boolean
// isValid.errors => null | [Errors]
API
__INLINE_CODE_0__
The definitions is a getter (function) so that you can pull it and mutate it awithout getting into trouble.
To see what definitions are available check out __INLINE_CODE_1__.
You can also see examples of how to use most of the definitions in the __INLINE_CODE_2__ folder. At time of writing there's good test coverage here for fields:
- __INLINE_CODE_3__
- __INLINE_CODE_4__
- __INLINE_CODE_5__
- __INLINE_CODE_6__
- __INLINE_CODE_7__
- __INLINE_CODE_8__ (box1, box2/ envelope)