Type::Tiny::ConstrainedObject - Online Linux Manual PageSection : 3pm
Updated : 2021-02-24
Source : perl v5.32.1
Note : User Contributed Perl Documentation
NAMEType::Tiny::ConstrainedObject − shared behavour for Type::Tiny::Class, etc
STATUSThis module is considered experiemental.
DESCRIPTION
MethodsThe following methods exist for Type::Tiny::Class, Type::Tiny::Role, Type::Tiny::Duck, and any type constraints that inherit from Object or Overload in Types::Standard. These methods will also work for Type::Tiny::Intersection if at least one of the types in the intersection provides these methods. These methods will also work for Type::Tiny::Union if all of the types in the union provide these methods. stringifies_to($constraint) Generates a new child type constraint which checks the object's stringification against a constraint. For example: my $type = Type::Tiny::Class−>new(class => 'URI');
my $child = $type−>stringifies_to( StrMatch[qr/^http:/] );
$child−>assert_valid( URI−>new("http://example.com/") );
In the above example, $child is a type constraint that checks objects are blessed into (or inherit from) the URI class, and when stringified (e.g. though overloading) the result matches the regular expression qr/^http:/. $constraint may be a type constraint, something that can be coerced to a type constraint (such as a coderef returning a boolean), a string of Perl code operating on $_, or a reference to a regular expression. So the following would work: my $child = $type−>stringifies_to( sub { qr/^http:/ } );
my $child = $type−>stringifies_to( qr/^http:/ );
my $child = $type−>stringifies_to( 'm/^http:/' );
my $child = $type−>where('"$_" =~ /^http:/');
numifies_to($constraint) The same as stringifies_to but checks numification. The following might be useful: use Types::Standard qw(Int Overload);
my $IntLike = Int | Overload−>numifies_to(Int)
with_attribute_values($attr1 => $constraint1, ...) This is best explained with an example: use Types::Standard qw(InstanceOf StrMatch);
use Types::Common::Numeric qw(IntRange);
my $person = InstanceOf['Local::Human'];
my $woman = $person−>with_attribute_values(
gender => StrMatch[ qr/^F/i ],
age => IntRange[ 18 => () ],
);
$woman−>assert_valid($alice);
This assertion will firstly check that $alice is a Local::Human, then check that $alice−>gender starts with an ‟F”, and lastly check that $alice−>age is an integer at least 18. Again, constraints can be type constraints, coderefs, strings of Perl code, or regular expressions. Technically the ‟attributes” don't need to be Moo/Moose/Mouse attributes, but any methods which can be called with no parameters and return a scalar.
BUGSPlease report any bugs to <https://github.com/tobyink/p5−type−tiny/issues>.
SEE ALSOType::Tiny::Manual. Type::Tiny.
AUTHORToby Inkster <tobyink@cpan.org>.
COPYRIGHT AND LICENCEThis software is copyright (c) 2019−2021 by Toby Inkster. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
DISCLAIMER OF WARRANTIESTHIS PACKAGE IS PROVIDED ‟AS IS” AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 0
Johanes Gumabo
Data Size : 11,835 byte
man-Type::Tiny::ConstrainedObject.3pmBuild : 2024-12-05, 20:55 :
Visitor Screen : x
Visitor Counter ( page / site ) : 2 / 198,846
Visitor ID : :
Visitor IP : 18.188.69.167 :
Visitor Provider : AMAZON-02 :
Provider Position ( lat x lon ) : 39.962500 x -83.006100 : x
Provider Accuracy Radius ( km ) : 1000 :
Provider City : Columbus :
Provider Province : Ohio , : ,
Provider Country : United States :
Provider Continent : North America :
Visitor Recorder : Version :
Visitor Recorder : Library :
Online Linux Manual Page : Version : Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page : Library : lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page : Library : lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base : Version : Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base : Library : lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36
Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.
ERROR : Need New Coding : (parse_manual_page_|249|Type::Tiny::ConstrainedObject.3pm|36/37|el══─{─══.|.el══─{─══. ds -- \|\(em\|
) (htmlprn|149|Type::Tiny::ConstrainedObject.3pm|36/37|.el══─{─══. ds -- — |.el══─{─══. ds -- \|\(em\|
) (parse_manual_page_|249|Type::Tiny::ConstrainedObject.3pm|43|br══─}─══|'br══─}─══
) (htmlprn|149|Type::Tiny::ConstrainedObject.3pm|43|'br══─}─══ |'br══─}─══
)