1Specio::Subs(3)       User Contributed Perl Documentation      Specio::Subs(3)
2
3
4

NAME

6       Specio::Subs - Make validation and coercion subs from Specio types
7

VERSION

9       version 0.47
10

SYNOPSIS

12         use Specio::Subs qw( Specio::Library::Builtins Specio::Library::Perl My::Lib );
13
14         if ( is_PackageName($var) ) { ... }
15
16         assert_Str($var);
17
18         my $person1 = to_Person($var);
19         my $person2 = force_Person($var);
20

DESCRIPTION

22       This module generates a set of helpful validation and coercion
23       subroutines for all of the types defined in one or more libraries.
24
25       To use it, simply import "Specio::Subs" passing a list of one or more
26       library names. This module will load those libraries as needed.
27
28       If any of the types in any libraries have names that do not work as
29       part of a Perl subroutine name, this module will throw an exception.
30
31       If you have Sub::Util or Sub::Name installed, one of those will be used
32       to name the generated subroutines.
33

"EXPORTS"

35       The following subs are created in the importing package:
36
37   is_$type($value)
38       This subroutine returns a boolean indicating whether or not the $value
39       is valid for the type.
40
41   assert_$type($value)
42       This subroutine dies if the $value is not valid for the type.
43
44   to_$type($value)
45       This subroutine attempts to coerce $value into the given type. If it
46       cannot be coerced it returns the original $value.
47
48       This is only created if the type has coercions.
49
50   force_$type($value)
51       This subroutine attempts to coerce $value into the given type, and dies
52       if it cannot do so.
53
54       This is only created if the type has coercions.
55

ADDITIONAL API

57       This module has a subroutine named "subs_installed_into". It is not
58       exported but it can be called by its fully qualified name. It accepts a
59       single argument, a package name. It returns a list of subs that it
60       generated and installed in the given package, if any.
61
62       This exists to make it easy to write a type library that combines other
63       library and generates helper subs for export all at once.
64

SUPPORT

66       Bugs may be submitted at
67       <https://github.com/houseabsolute/Specio/issues>.
68
69       I am also usually active on IRC as 'autarch' on "irc://irc.perl.org".
70

SOURCE

72       The source code repository for Specio can be found at
73       <https://github.com/houseabsolute/Specio>.
74

AUTHOR

76       Dave Rolsky <autarch@urth.org>
77
79       This software is Copyright (c) 2012 - 2021 by Dave Rolsky.
80
81       This is free software, licensed under:
82
83         The Artistic License 2.0 (GPL Compatible)
84
85       The full text of the license can be found in the LICENSE file included
86       with this distribution.
87
88
89
90perl v5.34.0                      2022-01-21                   Specio::Subs(3)
Impressum