In this video, you printed the fields the front desk books from and found two records that matched the schema but couldn’t be booked. Then you wrote checkRecord() to check each record against today’s date and the clinic’s data, its species and its opening hours, and flagged the two in the intake script.
Key Points
- Every note came back as a record. With the species, preferred date, and preferred time printed after the kind, all twelve notes came back from
askForJson()as records, and no note was held back. Every one of them matched the schema. - Rolo’s date has already passed. Today, in the video’s run, is December 1, 2026. Rolo’s owner asked for “yesterday afternoon”, and the model wrote that date down:
2026-11-30. It’s a real date in the right format, and it has already passed. - The clinic doesn’t treat Noodle. Noodle is a corn snake, and
data/clinic.jsonlists the species the clinic treats: dogs, cats, rabbits, guinea pigs, and ferrets. The note asks for an appointment, so its kind is"booking". And the prompt keeps any species the clinic doesn’t treat as the owner wrote it, so here it’s"corn snake". - Output varies. Your run’s wording will differ. In nine runs of the set behind this video, all with one provider, these two records came back this way every time.
- A schema checks the shape, not the truth. Here’s Rolo’s whole record from the run, next to what the schema allows for each field. Every field matches:
| Field | Value | The schema allows |
|---|---|---|
kind |
"booking" |
"booking" or "not_a_booking" |
species |
"guinea pig" |
a string or null |
petName |
"Rolo" |
a string or null |
problem |
"Frequent sneezing" |
a string or null |
urgency |
"soon" |
"routine", "soon", "urgent", or null |
preferredDate |
"2026-11-30" |
a string or null |
preferredTime |
"afternoon" |
a string or null |
- Two kinds of rule. This schema says what each value must look like, not whether a date has passed or the clinic treats a species. Your prompt gives the model today’s date and the clinic’s species to write the record, not to check it, and the model did what the prompt asked. It worked Rolo’s date out from the note and wrote Noodle’s species as the owner wrote it.
- The model’s job and your code’s job. The schema leaves the species open on purpose. Writing down what the note says is the model’s job. Deciding whether the clinic can book it is your code’s.
- Compare dates as text. A date written as year, month, then day, with two digits for the month and the day, sorts the same way as text, so the less than operator compares two of them as dates. The comparison only works on a real date written that way, and nothing checks that yet.
- Look the species up. The second check looks for the record’s species in the clinic’s list with
.includes(), one of the array methods the Functions You Can Pass Around course works with. Corn snake isn’t there, so it adds a problem. Both checks skip anull, because the note didn’t give that value. - Compare times with the opening hours. The clinic can’t book outside its opening hours either. So the third check takes a clock time, with a colon after a two-digit hour, like
10:00, and compares it with the opening hours, as text again. That’s why it looks for":"at index2. It skips any other time, likemorning. No note in this set asks for a time outside the hours, so it flags nothing here. - Flag each failing record. The intake script calls
checkRecord()after printing each record and prints any problems under it as flagged. It doesn’t send the record anywhere yet. In the run below, Noodle is flagged for the species and Rolo for the date, and the other ten records pass all three checks. - A later day flags more. The notes’ dates don’t change, but
todaycomes from your clock. Run the script on a later day, and more dates are flagged as before today. That’s the check working.