Test::Deep::HashRec - test hash entries for required and optional fields
version 0.001
cmp_deeply( $got, hashrec({ required => { count => any(1,2,3), b => ignore() }, optional => { name => { first => ignore(), last => ignore() } }, }), "we got a valid record", );
hashrec returns a Test::Deep comparator that asserts that:
hashrec
all required elements are present
nothing other than required and optional elements are present
all present elements match the comparator given for them
If you pass a true allow_unknown argument, then unknown elements will be permitted, and their values ignored.
allow_unknown
Ricardo Signes <rjbs@cpan.org>
This software is copyright (c) 2018 by Ricardo Signes.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Test::Deep::HashRec, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::Deep::HashRec
CPAN shell
perl -MCPAN -e shell install Test::Deep::HashRec
For more information on module installation, please visit the detailed CPAN module installation guide.