Lab: Apply the Attribute Pattern

Hi, i have some difficulty to understand how to modify the shape of collection about the “date_acquisition” field. In my point of view it is an attribute of the opera. I don’t understand the request on this field.
The “events” array could be transformed as
“events”: [ {“loaned_to_museum”: “”, “loaned_to_date”: “”} ]

Thanks in advice


The structure needs to account for all dates: “date_acquisition” and the dates at which the piece was loaned.
I hope this little hint helps you.


Thanks Daniel but i have always my doubt,
If i have 1 date_acquisition for each opera, the date when the musem has owned the opera in its property, why i must account more than 1 date?
Probably i don’t understand the semantic of date_acquisition field.
Moreover followng your suggestion i shaped events as [{“date_acquisition”: “”, “k”: “”, “v”: “”}] where k is the musem name and v the loan date but the validator doesn’t work.
Last consideration: the second item of the task use the word “migrate”. What does it mean in this context? To move this piece of information in another collection or other?

Thanks in advice

you have a date_aquisition not for each museum but for each item. So only one.
The magic with the attribute pattern is it’s very flexible: so you can have what you want in your k value. You can see here the document event like a pair description for the event and date of the event. the aquisition date is just a event like the other museum event.
Hope that’s help.


thanks for your explanation, now it’s clearer.


you’re welcome buddy :wink:

Thanks Olivier, you clarified my doubt.

I understand the problem and I resolved, but the validate_m320 doesn’t work like a expect. I tried copying the solution in file with the required name and below I copy the resolve:

C:\Users\xxxxxx\Downloads>validate_m320 pattern_attribute --file pattern_attribute.json --verbose
Answer Filename: C:/Users/jmedina/Downloads/pattern_attribute.json

(root): Additional property location is not allowed

1 Like

It looks like you have a property name location that is now supposed to be present.

“_id”: “”,
“title”: “”,
“artist”: “”,
“date_acquisition”: “”,
“location”: “”,
“on_display”: “”,
“in_house”: “”,
“events”: [{
“moma”: “”,
“louvres”: “”

Chapter 3 - Apply attribute pattern lab -
The schema that is shown to me in the problem is copy-pasted above. (For some reason this editor does not copy paste attribute types and leaves them blank.)
This schema has location.
But validator tells me that :
Additional property location is not allowed (when location itself is present in the given problem) ,
room is required , spot is required. (room and spot are never mentioned in the problem statement.)

Wasted 1 attempt for the lab.
I am using mac.

Because the attribute types starts with < and terminates with > just like HTML. So it is not interpreted correctly. That is why you have to put between pre or code html tag or triple back ticks.

In my version of the course the problem started with:

  "_id": "<objectId>",
  "title": "<string>",
  "artist": "<string>",
  "date_acquisition": "<date>",
  "room": "<string>",
  "spot": "<string>",
  "on_display": "<bool>",
  "in_house": "<bool>",
  "events": [{
    "moma": "<date>",
    "louvres": "<date>"

May be the course changed since then, but there is no location and room and spot are present.

So perhaps the lab is another one. Could you please provide screenshot of the lab pages?

Probably you use something like that:
./validate_m320 example --file pattern_attribute.json --verbose
and you need this one:
./validate_m320 pattern_attribute --file pattern_attribute.json --verbose

Have the same :slight_smile:

ok, I will try that. But that still does not explain how I will know about room and spot required fields if they are not present in the problem itself. ( Also about location field error - see above : [Cruz_58351] reply . )

As I wrote, the 2 fields were present in my (older) version of the lab. I see 2 possible thing:

  1. You are using a version of validate_m320 from a previous course
  2. They change the lab and forgot to update the validator