Wikibase::Datatype::Utils - Wikibase datatype utilities.
use Wikibase::Datatype::Utils qw(check_datetime check_entity check_language check_lexeme check_property check_sense); check_datetime($self, $key); check_entity($self, $key); check_language($self, $key); check_lexeme($self, $key); check_property($self, $key); check_sense($self, $key);
Datatype utilities for checking of data objects.
check_datetime
check_datetime($self, $key);
Check parameter defined by $key if it's datetime for Wikibase. Format of value is variation of ISO 8601 with some changes (like 00 as valid month).
$key
Returns undef.
check_entity
check_entity($self, $key);
Check parameter defined by $key if it's entity (/^Q\d+/).
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_sense
check_sense($self, $key);
Check parameter defined by $key if it's property (/^L\d+\-S\d+$/).
check_datetime(): Parameter '%s' has bad date time. Value: %s Parameter '%s' has bad date time day value. Value: %s Parameter '%s' has bad date time hour value. Value: %s Parameter '%s' has bad date time minute value. Value: %s Parameter '%s' has bad date time month value. Value: %s Parameter '%s' has bad date time second value. Value: %s 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."; check_sense(): Parameter '%s' must begin with 'L' and number, dash, S and number after it.
use strict; use warnings; use Wikibase::Datatype::Utils qw(check_datetime); my $self = { 'key' => '+0134-11-00T00:00:00Z', 'precision' => 10 }; check_datetime($self, 'key'); # Print out. print "ok\n"; # Output: # ok
use strict; use warnings; use Wikibase::Datatype::Utils qw(check_datetime); $Error::Pure::TYPE = 'Error'; my $self = { 'key' => '+0134-34-00T00:01:00Z', }; check_datetime($self, 'key'); # Print out. print "ok\n"; # Output: # #Error [/../Wikibase/Datatype/Utils.pm:?] Parameter 'key' has bad date time month value.
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.
use strict; use warnings; use Wikibase::Datatype::Utils qw(check_sense); my $self = { 'key' => 'L34727-S1', }; check_sense($self, 'key'); # Print out. print "ok\n"; # Output: # ok
use strict; use warnings; use Error::Pure; use Wikibase::Datatype::Utils qw(check_sense); $Error::Pure::TYPE = 'Error'; my $self = { 'key' => 'bad_sense', }; check_sense($self, 'key'); # Print out. print "ok\n"; # Output like: # #Error [/../Wikibase/Datatype/Utils.pm:?] Parameter 'key' must begin with 'L' and number, dash, S and number after it.
DateTime, Exporter, Error::Pure, List::Util, Readonly.
Wikibase datatypes.
https://github.com/michal-josef-spacek/Wikibase-Datatype
Michal Josef Špaček mailto:skim@cpan.org
http://skim.cz
© 2020-2023 Michal Josef Špaček
BSD 2-Clause License
0.31
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.