NAME

CMS::Drupal::Types - A Perl type library for working with Drupal

VERSION

version 0.94

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->{$_} );
      print "$_: '$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 non-empty string if present. May be omitted.

SEE ALSO

AUTHOR

Nick Tonkin <tonkin@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2015 by Nick Tonkin.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.