Although there are better data validation tools for perl, Assert::Refute can do this, providing a summary of detected discrepancies.
This example shows some stupid data format.
The same validation rules may be applied to incoming data (as here) or output of some function in either production or unit-test.
Expected input is JSON (and the script dies unless it's technically correct). This will pass validation:
Omitting required keys, adding extra ones, and changing the format of the existing ones will cause a failed test and a more detailed summary.