promptdojo_

Dataset schema validation — reject, quarantine, and the receipt rule — step 6 of 8

A batch of spam-classifier records just came off the extractor, headed for a training set. Write validate_batch(records) — the boundary in one function. Return two lists, (clean, flagged). A record is flagged if any check fails:

  • a REQUIRED field is missing (use the not in comprehension),
  • its label is not in LABELS,
  • its confidence is outside 0.0-1.0.

Check for missing fields first — the other checks index into keys that might not exist. The bottom of the starter prints the counts, then the label and confidence of each clean record.

Expected output:

2 3
spam 0.98
ham 0.91

full-screen editor opens — close anytime to keep reading.