Hi everyone,
I’m currently on day 4 stuck on test #14 of the “Build a Cargo Manifest Validator” lab.
I’ve checked multiple forum threads from the last few days (many people seem to be stuck on the same test), and I’ve compared my logic with several other solutions, but I still can’t understand why this specific test fails.
My validateManifest function seems to follow all the user stories:
returns “Missing” when a property is null, undefined, or absent
returns “Invalid” when the type or value is incorrect
returns an empty object {} when everything is valid
removes undefined properties before returning
handles non-object input by returning all fields as “Missing”
Hi @dhess, thanks for replying!
I just realised I accidentally pasted the wrong version of my code in the previous message, sorry, I am very tired.
Here is the correct and complete version of all my functions (normalizeUnits, validateManifest, and processManifest). This is the code that is currently failing test #14:
Yes, test #14 is the only one failing. Here is exactly what I see when I run the tests:// running tests
14. If the input manifest object is not valid, your validateManifest function should return an object describing missing and/or invalid properties.
// tests completed
So containerId seems to be handled correctly in both cases.
I also added the console.log inside validateManifest as you suggested, and when I test the case without containerId, I get:
Code
containerId is: undefined
And validateManifest returns:
Code
{ containerId: "Missing" }
So it seems to handle both null and undefined correctly.
If that part is working as expected, maybe the issue in test #14 is happening somewhere else in the flow (possibly in processManifest or normalizeUnits). I’m still trying to figure out where exactly it breaks.
dhess is suggesting that a “Missing” value actually means the object doesn’t actually have the property, not that its value is nullish (null/undefined).
Regardless, this isn’t the reason your code isn’t passing the test. I copied your most recent code revision, modified the actual line of code that was causing it to fail the automated test and it passed, in spite of the issue dhess was suggesting you look at.
I don’t want to give the answer away directly, but have a look at the specifications for each object property. Read them in detail. (I actually had the same bug before I passed it earlier - it’s easily done. )
Thank you so much, @Eth0! Your hint was exactly what I needed. I went back to the properties specifications like you suggested and I finally spotted the tiny detail I had misunderstood. It was indeed one of those easy-to-miss conditions — everything is passing now.
And a big thank you to @dhess as well for the patience and all the back-and-forth yesterday. I really appreciate the help from both of you!