Oddly enough, just this morning RJBS was writing about rx aka Data::Rx, which I think tries to do what you want. And if it doesn't, then the blog post mentions a couple more options, JSON Schema and Kwalify that I don't know much about.
In reply to Re: "Schema" specifier for perl in memory structures
by mirod
in thread "Schema" specifier for perl in memory structures
by zerohero
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |