view release on metacpan or search on metacpan
i18n/Aion/Type.ru-en.po view on Meta::CPAN
msgid "ÐÑовеÑÑеÑ, пÑÐ¸Ð½Ð°Ð´Ð»ÐµÐ¶Ð¸Ñ Ð»Ð¸ аÑгÑÐ¼ÐµÐ½Ñ ÐºÐ»Ð°ÑÑÑ."
msgstr "Checks whether the argument belongs to the class."
msgid "ÐÑовеÑÑеÑ, ÑÑо аÑгÑÐ¼ÐµÐ½Ñ Ð½Ðµ пÑÐ¸Ð½Ð°Ð´Ð»ÐµÐ¶Ð¸Ñ ÐºÐ»Ð°ÑÑÑ."
msgstr "Checks that the argument does not belong to the class."
msgid "ÐÑивеÑÑи `$value` к ÑипÑ, еÑли пÑиведение из Ñипа и ÑÑнкÑии наÑ
одиÑÑÑ Ð² `$self->{coerce}`."
msgstr "Cast `$value` to type if the cast from type and function is in `$self->{coerce}`."
msgid "ФоÑмиÑÑÐµÑ ÑообÑение оÑибки."
msgstr "Generates an error message."
msgid "ÐÑовеÑÑÐµÑ `$element` и вÑбÑаÑÑÐ²Ð°ÐµÑ ÑообÑение `detail`, еÑли ÑÐ»ÐµÐ¼ÐµÐ½Ñ Ð½Ðµ пÑÐ¸Ð½Ð°Ð´Ð»ÐµÐ¶Ð¸Ñ ÐºÐ»Ð°ÑÑÑ."
msgstr "Checks `$element` and throws a `detail` message if the element does not belong to the class."
msgid "ÐеÑÐµÐ²Ð¾Ð´Ð¸Ñ `$val` в ÑÑÑокÑ."
msgstr "Converts `$val` to a string."
msgid "ÐпÑеделÑеÑ, ÑÑо Ñип ÑвлÑеÑÑÑ Ð¿Ð¾Ð´Ñипом дÑÑгого `$type`."
msgstr "Specifies that a type is a subtype of another `$type`."
i18n/Aion/Type.ru-en.po view on Meta::CPAN
msgid "СпиÑок аÑгÑменÑов."
msgstr "List of arguments."
msgid "ÐÐ¼Ñ Ñипа."
msgstr "Type name."
msgid "РодиÑелÑÑкий Ñип."
msgstr "Parent type."
msgid "ÐкÑеÑÑÐ¾Ñ ÑообÑениÑ. ÐÑполÑзÑÐµÑ `&message` Ð´Ð»Ñ Ð³ÐµÐ½ÐµÑаÑии ÑообÑÐµÐ½Ð¸Ñ Ð¾Ð± оÑибке."
msgstr "Message accessor. Uses `&message` to generate an error message."
msgid "ÐкÑеÑÑÐ¾Ñ Ð·Ð°Ð³Ð¾Ð»Ð¾Ð²ÐºÐ° (иÑполÑзÑеÑÑÑ Ð´Ð»Ñ ÑÐ¾Ð·Ð´Ð°Ð½Ð¸Ñ ÑÑ
ÐµÐ¼Ñ **swagger**)."
msgstr "Header accessor (used to create the **swagger** schema)."
msgid "ÐкÑеÑÑÐ¾Ñ Ð¾Ð¿Ð¸ÑÐ°Ð½Ð¸Ñ (иÑполÑзÑеÑÑÑ Ð´Ð»Ñ ÑÐ¾Ð·Ð´Ð°Ð½Ð¸Ñ ÑÑ
ÐµÐ¼Ñ **swagger**)."
msgstr "Description accessor (used to create a **swagger** schema)."
msgid "ÐкÑеÑÑÐ¾Ñ Ð¿ÑимеÑа (иÑполÑзÑеÑÑÑ Ð´Ð»Ñ ÑÐ¾Ð·Ð´Ð°Ð½Ð¸Ñ ÑÑ
ÐµÐ¼Ñ **swagger**)."
msgstr "Example accessor (used to create the **swagger** schema)."
i18n/Aion/Types.ru-en.po view on Meta::CPAN
msgid "ÐеÑвÑй, вÑоÑой, ÑÑеÑий и пÑÑÑй аÑгÑÐ¼ÐµÐ½Ñ Ñипа."
msgstr "The first, second, third and fifth type arguments."
msgid "ÐÑполÑзÑеÑÑÑ Ð² `init_where`, `where` и `awhere`."
msgstr "Used in `init_where`, `where` and `awhere`."
msgid "`M` и `N` ÑокÑаÑение Ð´Ð»Ñ `SELF->{M}` и `SELF->{N}`."
msgstr "`M` and `N` are shorthand for `SELF->{M}` and `SELF->{N}`."
msgid "ÐÑполÑзÑеÑÑÑ Ñ `subtype` Ð´Ð»Ñ Ð²Ñвода ÑообÑÐµÐ½Ð¸Ñ Ð¾Ð± оÑибке, еÑли знаÑение иÑклÑÑÐ°ÐµÑ Ñип. Ð `$code` иÑполÑзÑеÑÑÑ: `SELF` - ÑекÑÑий Ñип, `ARGS`, `A`, `B`, `C`, `D...
msgstr "Used with `subtype` to print an error message if the value excludes the type. `$code` uses: `SELF` - the current type, `ARGS`, `A`, `B`, `C`, `D` - type arguments (if any) and a test value in `$_`. It can be converted to a string using `SELF-...
msgid "ÐобавлÑÐµÑ Ð½Ð¾Ð²Ð¾Ðµ пÑиведение (`$via`) к `$type` из `$from` Ñипа."
msgstr "Adds a new cast (`$via`) to `$type` from `$from` type."
msgid "ÐÐ¾Ð¶ÐµÑ Ð¸ÑполÑзоваÑÑ Ð¿Ð°ÑамеÑÑÑ Ñипа:"
msgstr "Can use parameters like:"
msgid "`coerce` вÑбÑаÑÑÐ²Ð°ÐµÑ Ð¸ÑклÑÑениÑ:"
msgstr "`coerce` throws exceptions:"
i18n/Aion/Types.ru-en.po view on Meta::CPAN
msgid "ÐпÑеделÑÐµÑ Ð·Ð½Ð°Ñение Ð´Ð»Ð¸Ð½Ñ Ð¾Ñ `from` до `to` или Ð¾Ñ 0 до `from`, еÑли `to` оÑÑÑÑÑÑвÑеÑ."
msgstr "Specifies a length value from `from` to `to`, or from 0 to `from` if `to` is missing."
msgid "Perl веÑÑии."
msgstr "Perl version."
msgid "СÑÑоки, вклÑÑÐ°Ñ ÑиÑла."
msgstr "Strings, including numbers."
msgid "СÑÑоки Unicode Ñ Ñлагом utf8 или еÑли декодиÑование в utf8 пÑоиÑÑ
Ð¾Ð´Ð¸Ñ Ð±ÐµÐ· оÑибок."
msgstr "Unicode strings with the utf8 flag or if decoding to utf8 occurs without errors."
msgid "ÐинаÑнÑе ÑÑÑоки без Ñлага utf8 и окÑеÑов Ñ Ð½Ð¾Ð¼ÐµÑами менÑÑе 128."
msgstr "Binary strings without the utf8 flag and octets with numbers less than 128."
msgid "СÑÑока наÑинаеÑÑÑ Ñ `begin`."
msgstr "The line starts with `begin`."
msgid "СÑÑока заканÑиваеÑÑÑ Ð½Ð° `end`."
msgstr "The line ends with `end`."
lib/Aion/Type.md view on Meta::CPAN
СвойÑÑво `init` не Ð¼Ð¾Ð¶ÐµÑ Ð¸ÑполÑзоваÑÑÑÑ Ñ `make`.
```perl
eval { Aion::Type->new(name=>"Rim", init => sub {...})->make(__PACKAGE__) }; $@ # ~> init_where won't work in Rim
```
ÐÑли подпÑогÑамма не Ð¼Ð¾Ð¶ÐµÑ Ð±ÑÑÑ Ñоздана, Ñо вÑбÑаÑÑваеÑÑÑ Ð¸ÑклÑÑение.
```perl
eval { Aion::Type->new(name=>"Rim")->make }; $@ # ~> syntax error
```
## make_arg ($pkg)
Ð¡Ð¾Ð·Ð´Ð°ÐµÑ Ð¿Ð¾Ð´Ð¿ÑогÑÐ°Ð¼Ð¼Ñ Ñ Ð°ÑгÑменÑами, коÑоÑÐ°Ñ Ð²Ð¾Ð·Ð²ÑаÑÐ°ÐµÑ Ñип.
```perl
BEGIN {
Aion::Type->new(name=>"Len", test => sub {
$Aion::Type::SELF->{args}[0] <= length($_) && length($_) <= $Aion::Type::SELF->{args}[1]
})->make_arg(__PACKAGE__);
}
"IX" ~~ Len[2,2] # => 1
```
ÐÑли подпÑогÑамма не Ð¼Ð¾Ð¶ÐµÑ Ð±ÑÑÑ Ñоздана, Ñо вÑбÑаÑÑваеÑÑÑ Ð¸ÑклÑÑение.
```perl
eval { Aion::Type->new(name=>"Rim")->make_arg }; $@ # ~> syntax error
```
## make_maybe_arg ($pkg)
Ð¡Ð¾Ð·Ð´Ð°ÐµÑ Ð¿Ð¾Ð´Ð¿ÑогÑÐ°Ð¼Ð¼Ñ Ñ Ð°ÑгÑменÑами, коÑоÑÐ°Ñ Ð²Ð¾Ð·Ð²ÑаÑÐ°ÐµÑ Ñип.
```perl
BEGIN {
Aion::Type->new(
name => "Enum123",
lib/Aion/Type.md view on Meta::CPAN
}
3 ~~ Enum123 # -> 1
3 ~~ Enum123[4,5,6] # -> ""
5 ~~ Enum123[4,5,6] # -> 1
```
ÐÑли подпÑогÑамма не Ð¼Ð¾Ð¶ÐµÑ Ð±ÑÑÑ Ñоздана, Ñо вÑбÑаÑÑваеÑÑÑ Ð¸ÑклÑÑение.
```perl
eval { Aion::Type->new(name=>"Rim")->make_maybe_arg }; $@ # ~> syntax error
```
## equal ($type)
Ð¢Ð¸Ð¿Ñ ÑавнÑ, еÑли они имеÑÑ Ð¾Ð´Ð¸Ð½Ð°ÐºÐ¾Ð²Ð¾Ðµ имÑ, одинаковое колиÑеÑÑво аÑгÑменÑов, ÑодиÑелÑÑкий ÑÐ»ÐµÐ¼ÐµÐ½Ñ Ð¸ аÑгÑменÑÑ ÑавнÑ.
```perl
my $Int = Aion::Type->new(name => "Int");
my $PositiveInt = Aion::Type->new(name => "PositiveInt", as => $Int);
my $AnotherInt = Aion::Type->new(name => "Int");
lib/Aion/Type.pm view on Meta::CPAN
push @{$Int->{coerce}}, [$Bool, sub { 0+$_ }];
push @{$Int->{coerce}}, [$Num, sub { int($_+.5) }];
$Int->coerce(5.5) # => 6
$Int->coerce(undef) # => 0
$Int->coerce("abc") # => abc
=head2 detail ($element, $feature)
Generates an error message.
my $Int = Aion::Type->new(name => "Int");
$Int->detail(-5, "Feature car") # => Feature car must have the type Int. The it is -5!
my $Num = Aion::Type->new(name => "Num", message => sub {
"Error: $_ is'nt $Aion::Type::SELF->{N}!"
});
$Num->detail("x", "car") # => Error: x is'nt car!
lib/Aion/Type.pm view on Meta::CPAN
}
"IX" ~~ Rim # => 1
The C<init> property cannot be used with C<make>.
eval { Aion::Type->new(name=>"Rim", init => sub {...})->make(__PACKAGE__) }; $@ # ~> init_where won't work in Rim
If the routine cannot be created, an exception is thrown.
eval { Aion::Type->new(name=>"Rim")->make }; $@ # ~> syntax error
=head2 make_arg ($pkg)
Creates a subroutine with arguments that returns a type.
BEGIN {
Aion::Type->new(name=>"Len", test => sub {
$Aion::Type::SELF->{args}[0] <= length($_) && length($_) <= $Aion::Type::SELF->{args}[1]
})->make_arg(__PACKAGE__);
}
"IX" ~~ Len[2,2] # => 1
If the routine cannot be created, an exception is thrown.
eval { Aion::Type->new(name=>"Rim")->make_arg }; $@ # ~> syntax error
=head2 make_maybe_arg ($pkg)
Creates a subroutine with arguments that returns a type.
BEGIN {
Aion::Type->new(
name => "Enum123",
test => sub { $_ ~~ [1,2,3] },
a_test => sub { $_ ~~ $Aion::Type::SELF->{args} },
)->make_maybe_arg(__PACKAGE__);
}
3 ~~ Enum123 # -> 1
3 ~~ Enum123[4,5,6] # -> ""
5 ~~ Enum123[4,5,6] # -> 1
If the routine cannot be created, an exception is thrown.
eval { Aion::Type->new(name=>"Rim")->make_maybe_arg }; $@ # ~> syntax error
=head2 equal ($type)
Types are equal if they have the same name, the same number of arguments, the parent element, and the arguments are equal.
my $Int = Aion::Type->new(name => "Int");
my $PositiveInt = Aion::Type->new(name => "PositiveInt", as => $Int);
my $AnotherInt = Aion::Type->new(name => "Int");
my $IntWithArgs = Aion::Type->new(name => "Int", args => [1, 2]);
my $AnotherIntWithArgs = Aion::Type->new(name => "Int", args => [1, 2]);
lib/Aion/Type.pm view on Meta::CPAN
=head2 name ()
Type name.
=head2 as ()
Parent type.
=head2 message (;&message)
Message accessor. Uses C<&message> to generate an error message.
=head2 title (;$title)
Header accessor (used to create the B<swagger> schema).
=head2 description (;$description)
Description accessor (used to create a B<swagger> schema).
=head2 example (;$example)
lib/Aion/Types.pm view on Meta::CPAN
where { $_ =~ N && $_ =~ M };
}
"Hi, my dear!" ~~ BeginAndEnd["Hi,", "!"]; # -> 1
"Hi my dear!" ~~ BeginAndEnd["Hi,", "!"]; # -> ""
"" . BeginAndEnd["Hi,", "!"] # => BeginAndEnd['Hi,', '!']
=head2 message ($code)
Used with C<subtype> to print an error message if the value excludes the type. C<$code> uses: C<SELF> - the current type, C<ARGS>, C<A>, C<B>, C<C>, C<D> - type arguments (if any) and a test value in C<$_>. It can be converted to a string using C<< S...
=head2 coerce ($type, from => $from, via => $via)
Adds a new cast (C<$via>) to C<$type> from C<$from> type.
BEGIN {
subtype Four => where {4 eq $_};
}
"4a" ~~ Four # -> ""
lib/Aion/Types.pm view on Meta::CPAN
=head2 Str
Strings, including numbers.
1.1 ~~ Str # -> 1
"" ~~ Str # -> 1
1.1.0 ~~ Str # -> ""
=head2 Uni
Unicode strings with the utf8 flag or if decoding to utf8 occurs without errors.
"â" ~~ Uni # -> 1
123 ~~ Uni # -> ""
do {no utf8; "â" ~~ Uni} # -> 1
=head2 Bin
Binary strings without the utf8 flag and octets with numbers less than 128.
123 ~~ Bin # -> 1
t/aion/type.t view on Meta::CPAN
#
# СвойÑÑво `init` не Ð¼Ð¾Ð¶ÐµÑ Ð¸ÑполÑзоваÑÑÑÑ Ñ `make`.
#
::like scalar do {eval { Aion::Type->new(name=>"Rim", init => sub {...})->make(__PACKAGE__) }; $@}, qr{init_where won't work in Rim}, 'eval { Aion::Type->new(name=>"Rim", init => sub {...})->make(__PACKAGE__) }; $@ # ~> init_where won\'t work in Rim'...
#
# ÐÑли подпÑогÑамма не Ð¼Ð¾Ð¶ÐµÑ Ð±ÑÑÑ Ñоздана, Ñо вÑбÑаÑÑваеÑÑÑ Ð¸ÑклÑÑение.
#
::like scalar do {eval { Aion::Type->new(name=>"Rim")->make }; $@}, qr{syntax error}, 'eval { Aion::Type->new(name=>"Rim")->make }; $@ # ~> syntax error'; undef $::_g0; undef $::_e0;
#
# ## make_arg ($pkg)
#
# Ð¡Ð¾Ð·Ð´Ð°ÐµÑ Ð¿Ð¾Ð´Ð¿ÑогÑÐ°Ð¼Ð¼Ñ Ñ Ð°ÑгÑменÑами, коÑоÑÐ°Ñ Ð²Ð¾Ð·Ð²ÑаÑÐ°ÐµÑ Ñип.
#
::done_testing; }; subtest 'make_arg ($pkg)' => sub {
BEGIN {
Aion::Type->new(name=>"Len", test => sub {
$Aion::Type::SELF->{args}[0] <= length($_) && length($_) <= $Aion::Type::SELF->{args}[1]
})->make_arg(__PACKAGE__);
}
local ($::_g0 = do {"IX" ~~ Len[2,2]}, $::_e0 = "1"); ::ok $::_g0 eq $::_e0, '"IX" ~~ Len[2,2] # => 1' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
#
# ÐÑли подпÑогÑамма не Ð¼Ð¾Ð¶ÐµÑ Ð±ÑÑÑ Ñоздана, Ñо вÑбÑаÑÑваеÑÑÑ Ð¸ÑклÑÑение.
#
::like scalar do {eval { Aion::Type->new(name=>"Rim")->make_arg }; $@}, qr{syntax error}, 'eval { Aion::Type->new(name=>"Rim")->make_arg }; $@ # ~> syntax error'; undef $::_g0; undef $::_e0;
#
# ## make_maybe_arg ($pkg)
#
# Ð¡Ð¾Ð·Ð´Ð°ÐµÑ Ð¿Ð¾Ð´Ð¿ÑогÑÐ°Ð¼Ð¼Ñ Ñ Ð°ÑгÑменÑами, коÑоÑÐ°Ñ Ð²Ð¾Ð·Ð²ÑаÑÐ°ÐµÑ Ñип.
#
::done_testing; }; subtest 'make_maybe_arg ($pkg)' => sub {
BEGIN {
Aion::Type->new(
name => "Enum123",
t/aion/type.t view on Meta::CPAN
}
local ($::_g0 = do {3 ~~ Enum123}, $::_e0 = do {1}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, '3 ~~ Enum123 # -> 1' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {3 ~~ Enum123[4,5,6]}, $::_e0 = do {""}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, '3 ~~ Enum123[4,5,6] # -> ""' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {5 ~~ Enum123[4,5,6]}, $::_e0 = do {1}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, '5 ~~ Enum123[4,5,6] # -> 1' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
#
# ÐÑли подпÑогÑамма не Ð¼Ð¾Ð¶ÐµÑ Ð±ÑÑÑ Ñоздана, Ñо вÑбÑаÑÑваеÑÑÑ Ð¸ÑклÑÑение.
#
::like scalar do {eval { Aion::Type->new(name=>"Rim")->make_maybe_arg }; $@}, qr{syntax error}, 'eval { Aion::Type->new(name=>"Rim")->make_maybe_arg }; $@ # ~> syntax error'; undef $::_g0; undef $::_e0;
#
# ## equal ($type)
#
# Ð¢Ð¸Ð¿Ñ ÑавнÑ, еÑли они имеÑÑ Ð¾Ð´Ð¸Ð½Ð°ÐºÐ¾Ð²Ð¾Ðµ имÑ, одинаковое колиÑеÑÑво аÑгÑменÑов, ÑодиÑелÑÑкий ÑÐ»ÐµÐ¼ÐµÐ½Ñ Ð¸ аÑгÑменÑÑ ÑавнÑ.
#
::done_testing; }; subtest 'equal ($type)' => sub {
my $Int = Aion::Type->new(name => "Int");
my $PositiveInt = Aion::Type->new(name => "PositiveInt", as => $Int);
my $AnotherInt = Aion::Type->new(name => "Int");