Lab: apply polymorphic pattern: getting validation error!

this is my attempted schema tried for this lab but getting this validation error
image

schema:

[{
 "_id": "<objectId>",
  "product_id": "<int>",
  "title": "<string>",
  "description": "<string>",
  "authors": ["<string>"],
  "format": [
  {
  "book": {
  "publisher": "<string>",
  "language": "<string>",
  "pages": "<int>",
  "catalogues": {
    "isbn10": "<string>",
    "isbn13": "<string>"
  }
  },
  "audiobook": {
   "narrator": "<string>",
  "publisher": "<string>",
  "language": "<string>",
  "length_minutes": "<int>"
  },
  "ebook": {
  "publisher": "<string>",
  "language": "<string>",
  "eformats": {
    "epub": {
      "pages": "<int>"
    },
    "pdf": {
      "pages": "<int>"
    }
  },
  "isbn10": "<string>"
  }
  }]
}]

what am i doing wrong here? thanks for looking into this, much appreciated…

also tried this schema as well:

[{
		"product_id": "<int>",
		"title": "<string>",
		"description": "<string>",
		"authors": ["<string>"]
},
{
  "_id": "<objectId>",
  "format": "<string>",
  "publisher": "<string>",
  "language": "<string>",
  "pages": "<int>",
  "catalogues": {
    "isbn10": "<string>",
    "isbn13": "<string>"
  }
}, {
  "_id": "<objectId>",
  "format": "<string>",
  "publisher": "<string>",
  "language": "<string>",
  "eformats": {
    "epub": {
      "pages": "<int>"
    },
    "pdf": {
      "pages": "<int>"
    }
  },
  "isbn10": "<string>"
},{
  "_id": "<objectId>",
  "format": "<string>",
  "authors": ["<string>"],
  "narrator": "<string>",
  "publisher": "<string>",
  "language": "<string>",
  "length_minutes": "<int>"
}]

still same validation error!!

and another schema as @Satyam has explained it in here Lab: Apply the Polymorphic Pattern What is the issue? - #5 by Han_Heloir

i tried to reflect those pointed out aspects in this following schema but still getting this validation error!!

[{
  "_id": "<objectId>",
  "format": "book",
  "product_id": "<int>",
  "title": "<string>",
  "description": "<string>",
  "authors": ["<string>"],
  "publisher": "<string>",
  "language": "<string>",
  "pages": "<int>",
  "catalogues": {
    "isbn10": "<string>",
    "isbn13": "<string>"
  }
}, {
  "_id": "<objectId>",
  "product_id": "<int>",
  "format": "ebook",
  "title": "<string>",
  "desc": "ebook",
  "authors": ["<string>"],
  "publisher": "<string>",
  "language": "<string>",
  "eformats": {
    "epub": {
      "pages": "<int>"
    },
    "pdf": {
      "pages": "<int>"
    }
  },
  "isbn10": "<string>"
},{
  "_id": "<objectId>",
  "product_id": "<int>",
  "format": "audiobook",
  "title": "<string>",
  "desc": "audiobook",
  "author": ["<string>"],
  "narrator": "<string>",
  "publisher": "<string>",
  "language": "<string>",
  "length_minutes": "<int>"
}]

what sense of understanding am i not getting from this lab properly… looking forward to your response!! thank you :slight_smile:

please check this post for a few key points you had to change but missed to do so: Lab Impossible to complete with just lecture knowledge (Apply the Polymorphic Pattern) - #2 by Yilmaz_Durmaz

and you can try --verbose flag to see the problem and also start from scratch on an empty file similar to the one I described in here: Chapter - 3: Applying Subset Pattern Lab - getting correct code without using proper schema for it - #4 by Yilmaz_Durmaz

1 Like

yeah, one document at a time did really helped me get through this lab, thanks :slight_smile:

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.