NAME

Mo::utils::Text - Mo text utilities.

SYNOPSIS

use Mo::utils::Text qw(check_no_null check_string_hex);

check_no_null($self, $key);
check_string_hex($self, $key);

DESCRIPTION

Mo utilities for checking of text values.

SUBROUTINES

check_no_null

check_no_null($self, $key);

Since version 0.01.

Check parameter defined by $key for a NULL character at the end of the string.

The check is skipped if the parameter does not exist or its value is undef.

Put error if check isn't ok.

Returns undef.

check_string_hex

check_string_hex($self, $key);

Since version 0.02.

Check parameter defined by $key for a hexadecimal string. The string may contain characters from a-f, A-F and 0-9.

The check is skipped if the parameter does not exist or its value is undef.

Put error if check isn't ok.

Returns undef.

ERRORS

check_no_null():
        Parameter '%s' must not contain NULL on the end of string.
                Value: %s

check_string_hex():
        Parameter '%s' must contain hexadecimal string.
                Value: %s

EXAMPLES

EXAMPLE1

use strict;
use warnings;

use Mo::utils::Text qw(check_no_null);

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

# Print out.
print "ok\n";

# Output:
# ok

EXAMPLE2

use strict;
use warnings;

use Error::Pure;
use Mo::utils::Text qw(check_no_null);

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

my $self = {
        'key' => "foo\0",
};
check_no_null($self, 'key');

# Output:
# #Error [../Text.pm:19] Parameter 'key' must not contain NULL on the end of string.

EXAMPLE3

use strict;
use warnings;

use Mo::utils::Text qw(check_string_hex);

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

# Print out.
print "ok\n";

# Output:
# ok

EXAMPLE4

use strict;
use warnings;

use Error::Pure;
use Mo::utils::Text qw(check_string_hex);

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

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

# Output:
# #Error [../Text.pm:33] Parameter 'key' must contain hexadecimal string.

DEPENDENCIES

Exporter, Error::Pure, Readonly.

SEE ALSO

Mo

Micro Objects. Mo is less.

Mo::utils

Mo utilities.

Mo::utils::Array

Mo array utilities.

Mo::utils::Hash

Mo hash utilities.

REPOSITORY

https://github.com/michal-josef-spacek/Mo-utils-Text

AUTHOR

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

http://skim.cz

LICENSE AND COPYRIGHT

© 2026 Michal Josef Špaček

BSD 2-Clause License

VERSION

0.03