All problems
Tool Argument Schema Check
Problem
Validate tool arguments against a schema mapping each field to 'string', 'number', or 'boolean'. Return a sorted list of problems: 'field:missing' for absent fields and 'field:type' for wrong types.
Booleans do not count as numbers, and only the first problem per field is reported.
Hint
Handle the missing case before inspecting the value type.
Test cases
case 1
in: [{"q":"x"},{"q":"string"}]
expected: []
case 2
in: [{},{"q":"string"}]
expected: ["q:missing"]
case 3
in: [{"q":5},{"q":"string"}]
expected: ["q:type"]
case 4
in: [{"q":"x","n":2,"f":true},{"n":"number","f":"boolean"}]
expected: []
case 5
in: [{"n":true},{"n":"number"}]
expected: ["n:type"]
Starter codePython
def tool_argument_schema_check(arguments, schema):
# Your code here
pass5 test cases · run your code against them in the editor