Command Palette

Search for a command to run...

Hectal
Phase 7: Tools and Function Calling
LLM Engineering · Exercise 2 of 6 PreviousNext
Intermediate

Validate arguments against a schema

Write validate(schema, args) that returns a list of problem strings (empty when the arguments are fine). schema has properties (each with a type of "string" or "integer") and required.

Problems, in this order: first, for each name in required that is missing: "missing required argument: <name>". Then, for each key in args in order: "unknown argument: <key>" if the schema has no such property, or "<key>: expected <type>" if the value has the wrong type. A bool is not an integer.

What Check tests

  1. Good arguments give []
  2. A missing required argument is reported
  3. A wrong type is reported
  4. An unknown argument is reported
  5. A boolean is not an integer
  6. All problems are reported together

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

main.py
Sign in to run your code.

Output

Press Run to see what your program prints.