clarkie / dynogels

DynamoDB data mapper for node.js. Originally forked from https://github.com/ryanfitz/vogels

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Understand cause of an exception

mikebrules opened this issue · comments

Hello - I'm trying to understand the cause of an exception I see when my stack starts up, and which I can't find any background on -

Error: Cannot add other alternatives without at least one schema

I am defining a schema and using spread to pull in a Joi Objtect defined in a different file; i.e.

return dynogels.define('Stories', {
hashKey: 'assetId',
schema: {
  ...validators
},
tableName

where ...validators is this...

 export default Joi.object({
...metaPartial,
...coverImagePartial,
 title: Title.required(),
 summary: Summary.required(),
 assetType: AssetType.only(ASSET_TYPE_STORY).required(),
 type: StoryType.default(ARTICLE),
 blocks: Joi
   .array()
   .items(textBlockValidator, promoBlockValidator, embedBlockValidator)
   .default([])
  });

I can't understand what the "alternatives" relates to?

Many thanks

Mike

Using ...validators makes no sense here, since the exported object is a Joi schema object. You're copying the attributes of the schema object and treating those as schemas, which is nonsense. Just do schema: validators.

Also, this is a Joi question, not a Dynogels question.