NAME
CMS::Drupal::Types - A Perl type library for working with Drupal
VERSION
version 0.092
SYNOPSIS
use Types::Standard;
use CMS::Drupal::Types qw/ :all /;
USAGE
You can use this module to import Type::Tiny-style types relevant to Drupal into your program. Use the syntax shown above and the types will be available as object attributes.
If you want to use the types to validate parameters passed to a method or a sub, use the following syntax as an example:
use CMS::Drupal::Types qw/ DBName DBDriver DBUsername DBPassword /;
use Types::Standard qw/ Optional Maybe Str StrMatch Int slurpy Dict /;
use Type::Params qw/ compile /;
sub my_sub {
my $args = { @_ };
my %types = (
database => DBName,
driver => DBDriver,
username => DBUsername,
password => DBPassword,
);
for( keys %$args ) {
my $validate = compile( slurpy Dict [ $_ => $types{$_} ]);
my ($param) = $validate->( $_ => $args->{$_} );
say "$_: '$args->{$_}' passed";
}
}
TYPES
DBName Must be a non-empty string.
DBDriver Must be one of 'mysql', 'Pg', or 'SQLite'.
DBUsername Must be a string if present. May be empty. May be omitted.
DBPassword Must be a string if present. May be empty. May be omitted.
DBHost Must be a string if present. May be empty. May be omitted.
DBPort Must be an integer if present. May be empty. May be omitted.
DBPrefix Must be a string ending in an underscore if present. May be omitted.
AUTHOR
Author: Nick Tonkin (tonkin@cpan.org)
COPYRIGHT
Copyright (c) 2015 Nick Tonkin. All rights reserved.
LICENSE
You may distribute this module under the same license as Perl itself.