NAME
    Mo::utils::Array - Mo array utilities.

SYNOPSIS
     use Mo::utils::Array qw(check_array check_array_object check_array_required check_array_strings);

     check_array($self, $key);
     check_array_object($self, $key, $class);
     check_array_required($self, $key);
     check_array_strings($self, $key, $strings_ar);

DESCRIPTION
    Mo array utilities for checking of data objects.

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

    *Since version 0.01.*

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

    Put error if check isn't ok.

    Returns undef.

  "check_array_object"
     check_array_object($self, $key, $class);

    *Since version 0.01.*

    Check parameter defined by $key which is reference to array with
    instances of some object type ($class).

    Put error if check isn't ok.

    Returns undef.

  "check_array_required"
     check_array_required($self, $key);

    *Since version 0.01.*

    Check parameter defined by $key which is reference to array for at least
    one value inside.

    Put error if check isn't ok.

    Returns undef.

  "check_array_strings"
     check_array_strings($self, $key, $strings_ar);

    *Since version 0.02.*

    Check parameter defined by $key which is reference to array with strings
    defined by $strings_ar which is reference to array.

    Put error if check isn't ok.

    Returns undef.

ERRORS
     check_array():
             Parameter '%s' must be a array.
                     Value: %s
                     Reference: %s

     check_array_object():
             Parameter '%s' must be a array.
                     Value: %s
                     Reference: %s
             Parameter '%s' with array must contain '%s' objects.
                     Value: %s
                     Reference: %s

     check_array_required():
             Parameter '%s' is required.
             Parameter '%s' must be a array.
                     Value: %s
                     Reference: %s
             Parameter '%s' with array must have at least one item.

     check_array_strings():
             Parameter '%s' must be a array.
                     Value: %s
                     Reference: %s
             Parameter '%s' must be one of the defined strings.
                     Value: %s
                     Possible strings: %s
             Parameter '%s' must contain a list of strings.
                     Value: %s
                     Reference: %s
             Parameter '%s' must have right string definition.
             Parameter '%s' must have strings definition.

EXAMPLE1
     use strict;
     use warnings;

     use Mo::utils::Array qw(check_array);

     my $self = {
             'key' => ['foo'],
     };
     check_array($self, 'key');

     # Print out.
     print "ok\n";

     # Output:
     # ok

EXAMPLE2
     use strict;
     use warnings;

     use Error::Pure;
     use Mo::utils::Array qw(check_array);

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

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

     # Print out.
     print "ok\n";

     # Output like:
     # #Error [..Array.pm:?] Parameter 'key' must be a array.

EXAMPLE3
     use strict;
     use warnings;

     use Mo::utils::Array qw(check_array_object);
     use Test::MockObject;

     my $self = {
             'key' => [
                     Test::MockObject->new,
             ],
     };
     check_array_object($self, 'key', 'Test::MockObject');

     # Print out.
     print "ok\n";

     # Output:
     # ok

EXAMPLE4
     use strict;
     use warnings;

     use Error::Pure;
     use Mo::utils::Array qw(check_array_object);

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

     my $self = {
             'key' => [
                     'foo',
             ],
     };
     check_array_object($self, 'key', 'Test::MockObject');

     # Print out.
     print "ok\n";

     # Output like:
     # #Error [..Array.pm:?] Parameter 'key' with array must contain 'Test::MockObject' objects.

EXAMPLE5
     use strict;
     use warnings;

     use Mo::utils::Array qw(check_array_required);

     my $self = {
             'key' => ['value'],
     };
     check_array_required($self, 'key');

     # Print out.
     print "ok\n";

     # Output:
     # ok

EXAMPLE6
     use strict;
     use warnings;

     use Error::Pure;
     use Mo::utils::Array qw(check_array_required);

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

     my $self = {
             'key' => [],
     };
     check_array_required($self, 'key');

     # Print out.
     print "ok\n";

     # Output like:
     # #Error [..Array.pm:?] Parameter 'key' with array must have at least one item.

EXAMPLE7
     use strict;
     use warnings;

     use Mo::utils::Array qw(check_array_strings);

     my $self = {
             'key' => ['value'],
     };
     check_array_strings($self, 'key', ['value']);

     # Print out.
     print "ok\n";

     # Output:
     # ok

EXAMPLE8
     use strict;
     use warnings;

     use Error::Pure;
     use Mo::utils::Array qw(check_array_strings);

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

     my $self = {
             'key' => ['bad'],
     };
     check_array_strings($self, 'key', ['value']);

     # Print out.
     print "ok\n";

     # Output like:
     # #Error [..Array.pm:?] Parameter 'key' must be one of the defined strings.

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

SEE ALSO
    Mo  Micro Objects. Mo is less.

    Mo::utils
        Mo utilities.

    Mo::utils::Hash
        Mo hash utilities.

    Mo::utils::Language
        Mo language utilities.

    Mo::utils::CSS
        Mo CSS utilities.

    Wikibase::Datatype::Utils
        Wikibase datatype utilities.

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

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

    <http://skim.cz>

LICENSE AND COPYRIGHT
    © 2025 Michal Josef Špaček

    BSD 2-Clause License

VERSION
    0.02

