The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Test::Deep::HashRec - test hash entries for required and optional fields

VERSION

version 0.001

FUNCTIONS

hashrec

  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:

  • 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.

AUTHOR

Ricardo Signes <rjbs@cpan.org>

COPYRIGHT AND LICENSE

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.