NAME
Wikibase::Datatype::Utils - Wikibase datatype utilities.
SYNOPSIS
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
);
DESCRIPTION
Datatype utilities for checking of data objects.
VARIABLES
$SKIP_CHECK_LANG
Boolean variable to skip check of right language.
Default value is 0, checking is working.
@LANGUAGE_CODES
List of supported language codes defined by user.
Default value is (), checking official language codes.
SUBROUTINES
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).
Returns undef.
check_entity
check_entity(
$self
,
$key
);
Check parameter defined by $key
if it's entity (/^Q\d+/).
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.
Returns undef.
check_lexeme
check_lexeme(
$self
,
$key
);
Check parameter defined by $key
if it's entity (/^L\d+/).
Returns undef.
check_property
check_property(
$self
,
$key
);
Check parameter defined by $key
if it's property (/^P\d+/).
Returns undef.
check_sense
check_sense(
$self
,
$key
);
Check parameter defined by $key
if it's property (/^L\d+\-S\d+$/).
Returns undef.
ERRORS
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():
check_language():
Language code
'%s'
isn't code supported by Wikibase.
check_lexeme():
check_property():
check_sense():
EXAMPLE1
EXAMPLE2
EXAMPLE3
EXAMPLE4
use
strict;
use
warnings;
use
Error::Pure;
$Error::Pure::TYPE
=
'Error'
;
my
$self
= {
'key'
=>
'bad_entity'
,
};
check_entity(
$self
,
'key'
);
# Print out.
"ok\n"
;
# Output like:
# #Error [/../Wikibase/Datatype/Utils.pm:?] Parameter 'key' must begin with 'Q' and number after it.
EXAMPLE5
EXAMPLE6
use
strict;
use
warnings;
use
Error::Pure;
$Error::Pure::TYPE
=
'Error'
;
my
$self
= {
'key'
=>
'bad_entity'
,
};
check_lexeme(
$self
,
'key'
);
# Print out.
"ok\n"
;
# Output like:
# #Error [/../Wikibase/Datatype/Utils.pm:?] Parameter 'key' must begin with 'L' and number after it.
EXAMPLE7
EXAMPLE8
use
strict;
use
warnings;
use
Error::Pure;
$Error::Pure::TYPE
=
'Error'
;
my
$self
= {
'key'
=>
'bad_property'
,
};
check_property(
$self
,
'key'
);
# Print out.
"ok\n"
;
# Output like:
# #Error [/../Wikibase/Datatype/Utils.pm:?] Parameter 'key' must begin with 'P' and number after it.
EXAMPLE9
EXAMPLE10
use
strict;
use
warnings;
use
Error::Pure;
$Error::Pure::TYPE
=
'Error'
;
my
$self
= {
'key'
=>
'bad_sense'
,
};
check_sense(
$self
,
'key'
);
# Print out.
"ok\n"
;
# Output like:
# #Error [/../Wikibase/Datatype/Utils.pm:?] Parameter 'key' must begin with 'L' and number, dash, S and number after it.
DEPENDENCIES
DateTime, Exporter, Error::Pure, List::Util, Readonly.
SEE ALSO
- Wikibase::Datatype
-
Wikibase datatypes.
- Mo::utils
-
Mo utilities.
- Mo::utils::Language
-
Mo language utilities.
REPOSITORY
https://github.com/michal-josef-spacek/Wikibase-Datatype
AUTHOR
Michal Josef Špaček mailto:skim@cpan.org
LICENSE AND COPYRIGHT
© 2020-2025 Michal Josef Špaček
BSD 2-Clause License
VERSION
0.37