This file is indexed.

/usr/share/perl5/Type/Tiny/Manual/UsingWithOther.pod is in libtype-tiny-perl 1.000005-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
=pod

=encoding utf-8

=for stopwords inlinable

=head1 NAME

Type::Tiny::Manual::UsingWithOther - how to use Type::Tiny and Type::Library with other OO frameworks

=head1 DESCRIPTION

=head2 Class::InsideOut

You want L<Class::InsideOut> 1.13 or above, which has support for blessed
and overloaded objects (including Type::Tiny type constraints) for the
C<get_hook> and C<set_hook> options.

   {
      package Person;
      
      use Class::InsideOut qw( public );
      use Types::Standard qw( Str Int );
      use Type::Utils qw( declare as where inline_as coerce from );
      
      public name => my %_name, {
         set_hook => Str,
      };
      
      my $PositiveInt = declare
         as        Int,
         where     {  $_ > 0  },
         inline_as { "$_ =~ /^[0-9]+\$/ and $_ > 0" };
      
      coerce $PositiveInt, from Int, q{ abs $_ };
      
      public age => my %_age, {
         set_hook => sub { $_ = $PositiveInt->assert_coerce($_) },
      };
      
      sub get_older {
         my $self = shift;
         my ($years) = @_;
         $PositiveInt->assert_valid($years);
         $self->_set_age($self->age + $years);
      }
   }

I probably need to make coercions a little prettier.

B<< See also: >> C<< t/25_accessor_hooks_typetiny.t >> and
C<< t/Object/HookedTT.pm >> in the Class::InsideOut test suite; and the
L<Class-InsideOut integration tests|https://github.com/tobyink/p5-type-tiny/tree/master/t/30-integration/Class-InsideOut>
in the Type::Tiny test suite.

=head2 Params::Check and Object::Accessor

The Params::Check C<< allow() >> function, the C<allow> option for the
Params::Check C<< check() >> function, and the input validation mechanism
for Object::Accessor all work in the same way, which is basically a
limited pure-Perl implementation of the smart match operator. While this
doesn't directly support Type::Tiny constraints, it does support coderefs.
You can use Type::Tiny's C<compiled_check> method to obtain a suitable
coderef.

B<< L<Param::Check> example: >>

   my $tmpl = {
      name => { allow => Str->compiled_check },
      age  => { allow => Int->compiled_check },
   };
   check($tmpl, { name => "Bob", age => 32 })
      or die Params::Check::last_error();

B<< L<Object::Accessor> example: >>

   my $obj = Object::Accessor->new;
   $obj->mk_accessors(
      { name => Str->compiled_check },
      { age  => Int->compiled_check },
   );

B<< Caveat: >> Object::Accessor doesn't die when a value fails to meet its
type constraint; instead it outputs a warning to STDERR. This behaviour can
be changed by setting C<< $Object::Accessor::FATAL = 1 >>.

B<< See also: >> The
L<Object-Accessor integration tests|https://github.com/tobyink/p5-type-tiny/tree/master/t/30-integration/Object-Accessor>
in the Type::Tiny test suite.

=head2 Validation::Class::Simple

You want L<Validation::Class::Simple> 7.900017 or above.

The C<to_TypeTiny> function from L<Types::TypeTiny> can be used to create
a Type::Tiny type constraint from a Validation::Class::Simple object (and
probably from Validation::Class, but this is untested).

   use Types::TypeTiny qw( to_TypeTiny );
   use Validation::Class::Simple;
   
   my $type = to_TypeTiny Validation::Class::Simple->new(
      fields => {
         name => {
            required => 1,
            pattern  => qr{^\w+(\s\w+)*$},
            filters  => ["trim", "strip"],
         },
         email => { required => 1, email => 1 },
         pass  => { required => 1, min_length => 6 },
      },
   );
   
   # true
   $type->check({
      name   => "Toby Inkster",
      email  => "tobyink@cpan.org",
      pass   => "foobar",
   });
   
   # false
   $type->check({
      name   => "Toby Inkster ",    # trailing whitespace
      email  => "tobyink@cpan.org",
      pass   => "foobar",
   });
   
   # coercion from HashRef uses the filters defined above
   my $fixed = $type->coerce({
      name   => "Toby Inkster ",    # trailing whitespace
      email  => "tobyink@cpan.org",
      pass   => "foobar",
   });
   
   # true
   $type->check($fixed);

Type constraints built with Validation::Class::Simple are not inlinable, so
won't be as fast as C<Dict> from L<Types::Standard>, but the filters are a
pretty useful feature. (Note that filters are explicitly I<ignored> for type
constraint checking, and only come into play for coercion.)

B<< See also: >> The
L<Validation-Class-Simple integration tests|https://github.com/tobyink/p5-type-tiny/tree/master/t/30-integration/Validation-Class-Simple>
in the Type::Tiny test suite.

=head1 AUTHOR

Toby Inkster E<lt>tobyink@cpan.orgE<gt>.

=head1 COPYRIGHT AND LICENCE

This software is copyright (c) 2013-2014 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.

=head1 DISCLAIMER OF WARRANTIES

THIS 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.

=cut