Wikibase::Datatype::Utils - Wikibase datatype utilities.
use Wikibase::Datatype::Utils qw(check_entity check_language check_lexeme check_property); check_entity($self, $key); check_language($self, $key); check_lexeme($self, $key); check_property($self, $key);
Datatype utilities for checking of data objects.
check_entity
check_entity($self, $key);
Check parameter defined by $key if it's entity (/^Q\d+/).
$key
Returns undef.
check_language
check_language($self, $key);
Check parameter defined by $key if it's ISO 639-1 language code and if language exists.
check_lexeme
check_lexeme($self, $key);
Check parameter defined by $key if it's entity (/^L\d+/).
check_property
check_property($self, $key);
Check parameter defined by $key if it's property (/^P\d+/).
check_entity(): Parameter '%s' must begin with 'Q' and number after it."; check_language(): Language code '%s' isn't ISO 639-1 code. Language with ISO 639-1 code '%s' doesn't exist. check_lexeme(): Parameter '%s' must begin with 'L' and number after it."; check_property(): Parameter '%s' must begin with 'P' and number after it.";
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
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.
use strict; use warnings; use Wikibase::Datatype::Utils qw(check_lexeme); my $self = { 'key' => 'L123', }; check_lexeme($self, 'key'); # Print out. print "ok\n"; # Output: # ok
use strict; use warnings; use Error::Pure; use Wikibase::Datatype::Utils qw(check_lexeme); $Error::Pure::TYPE = 'Error'; my $self = { 'key' => 'bad_entity', }; check_lexeme($self, 'key'); # Print out. print "ok\n"; # Output like: # #Error [/../Wikibase/Datatype/Utils.pm:?] Parameter 'key' must begin with 'L' and number after it.
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
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.
Exporter, Error::Pure, List::Util, Locale::Language, Readonly.
Wikibase datatypes.
https://github.com/michal-josef-spacek/Wikibase-Datatype
Michal Josef Špaček mailto:skim@cpan.org
http://skim.cz
© 2020-2022 Michal Josef Špaček
BSD 2-Clause License
0.20
To install Wikibase::Datatype, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Wikibase::Datatype
CPAN shell
perl -MCPAN -e shell install Wikibase::Datatype
For more information on module installation, please visit the detailed CPAN module installation guide.