NAME
    Mo::utils::Hash - Mo hash utilities.

SYNOPSIS
     use Mo::utils::Hash qw(check_hash check_hash_keys check_hash_optional_keys);

     check_hash($self, $key);
     check_hash_keys($self, $key, @keys);
     check_hash_optional_keys($self, $key, @optional_root_keys);

DESCRIPTION
    Utilities for checking of hash values.

SUBROUTINES
  "check_hash"
     check_hash($self, $key);

    *Since version 0.01.*

    Check parameter defined by $key which is reference to hash.

    Put error if check isn't ok.

    Returns undef.

  "check_hash_keys"
     check_hash_keys($self, $key, @keys);

    *Since version 0.02.*

    Check parameter defined by $key which contain hash keys defined by
    @keys.

    Put error if check isn't ok.

    Returns undef.

  "check_hash_optional_keys"
     check_hash_optional_keys($self, $key, @optional_root_keys);

    *Since version 0.03.*

    Check parameter defined by $key which contain different key than
    @optional_root_keys.

    Put error if check isn't ok.

    Return undef.

ERRORS
     check_hash():
             Parameter '%s' isn't hash reference.
                     Reference: %s

     check_hash_keys():
             Expected keys doesn't exists.
             Parameter '%s' doesn't contain expected keys.
                     Keys: %s

     check_hash_optional_keys():
             Parameter '%s' isn't hash reference.
                     Reference: %s
             Parameter '%s' contain bad hash key.",
                     Bad key: %s

EXAMPLES
  EXAMPLE1
     use strict;
     use warnings;

     use Mo::utils::Hash qw(check_hash);

     my $self = {
             'key' => {},
     };
     check_hash($self, 'key');

     # Print out.
     print "ok\n";

     # Output:
     # ok

  EXAMPLE2
     use strict;
     use warnings;

     use Error::Pure;
     use Mo::utils::Hash qw(check_hash);

     $Error::Pure::TYPE = 'Error';

     my $self = {
             'key' => 'bad',
     };
     check_hash($self, 'key');

     # Print out.
     print "ok\n";

     # Output like:
     # #Error [..Hash.pm:?] Parameter 'key' isn't hash reference.

  EXAMPLE3
     use strict;
     use warnings;

     use Mo::utils::Hash 0.02 qw(check_hash_keys);

     my $self = {
             'key' => {
                     'first' => {
                            'second' => 'value',
                     },
             },
     };
     check_hash_keys($self, 'key', 'first', 'second');

     # Print out.
     print "ok\n";

     # Output:
     # ok

  EXAMPLE4
     use strict;
     use warnings;

     use Error::Pure;
     use Mo::utils::Hash 0.02 qw(check_hash_keys);

     $Error::Pure::TYPE = 'Error';

     my $self = {
             'key' => {
                     'first' => {
                             'second_typo' => 'value',
                     }
             },
     };
     check_hash_keys($self, 'key', 'first', 'second');

     # Print out.
     print "ok\n";

     # Output like:
     # #Error [..Hash.pm:?] Parameter 'key' doesn't contain expected keys.

DEPENDENCIES
    Exporter, Error::Pure, List::Util, Readonly.

SEE ALSO
    Mo::utils
        Mo utilities.

REPOSITORY
    <https://github.com/michal-josef-spacek/Mo-utils-Hash>

AUTHOR
    Michal Josef Špaček <mailto:skim@cpan.org>

    <http://skim.cz>

LICENSE AND COPYRIGHT
    © 2025-2026 Michal Josef Špaček

    BSD 2-Clause License

VERSION
    0.03

