|
I am using Data::Domain to validate a complex (and relatively large)
YAML file. Once validated I need to count the elements meaning a
double pass. To do this I would love to see '-hit' and '-miss' options
which take a coderef to be run upon a hit and miss
respectively. Laurent reminded me of lazy constructors as a possibility
but I think that this might cause the Data::Domain structure(s) to
end up looking ugly.
My proposal (which I've implemented, patch available if Laurent would
like it) would make a very simple example look something like:
return Struct(
headers => Struct(
-optional => 1,
header_is => List(
-optional => 1,
-all => String(
-hit => sub { warn "got it!" },
-miss => sub { warn "missed" }
)
),
)
);
The theory is already possible at the moment just with a little more
hassle. Although I'm going to keep using my patched version I'd love
to know what others think i.e. am I making DD do too much?
|