NAME
Wikibase::Datatype::Utils - Wikibase datatype utilities.
SYNOPSIS
use Wikibase::Datatype::Utils qw(check_entity);
check_entity($self, $key);
check_property($self, $key);
DESCRIPTION
Datatype utilities for checking of data objects.
SUBROUTINES
check_entity
check_entity($self, $key);
Check parameter defined by $key
whith is entity (/^Q\d+/).
Returns undef.
check_property
check_property($self, $key);
Check parameter defined by $key
whith is property (/^P\d+/).
Returns undef.
ERRORS
check_entity():
Parameter '%s' must begin with 'Q' and number after it.";
check_property():
Parameter '%s' must begin with 'P' and number after it.";
EXAMPLE1
use strict;
use warnings;
use Wikibase::Datatype::Utils qw(check_entity);
my $self = {
'key' => 'Q123',
};
check_entity($self, 'key');
# Print out.
print "ok\n";
# Output:
# ok
EXAMPLE2
use strict;
use warnings;
use Error::Pure;
use Wikibase::Datatype::Utils qw(check_entity);
$Error::Pure::TYPE = 'Error';
my $self = {
'key' => 'bad_entity',
};
check_entity($self, 'key');
# Print out.
print "ok\n";
# Output like:
# #Error [/../Wikibase/Datatype/Utils.pm:?] Parameter 'key' must begin with 'Q' and number after it.
EXAMPLE3
use strict;
use warnings;
use Wikibase::Datatype::Utils qw(check_property);
my $self = {
'key' => 'P123',
};
check_property($self, 'key');
# Print out.
print "ok\n";
# Output:
# ok
EXAMPLE4
use strict;
use warnings;
use Error::Pure;
use Wikibase::Datatype::Utils qw(check_property);
$Error::Pure::TYPE = 'Error';
my $self = {
'key' => 'bad_property',
};
check_property($self, 'key');
# Print out.
print "ok\n";
# Output like:
# #Error [/../Wikibase/Datatype/Utils.pm:?] Parameter 'key' must begin with 'P' and number after it.
DEPENDENCIES
Exporter, Error::Pure, Readonly.
SEE ALSO
- Wikibase::Datatype
-
Wikibase datatypes.
REPOSITORY
https://github.com/michal-josef-spacek/Wikibase-Datatype
AUTHOR
Michal Josef Špaček mailto:skim@cpan.org
LICENSE AND COPYRIGHT
© Michal Josef Špaček 2020
BSD 2-Clause License
VERSION
0.01