NAME

Data::Type - versatile data/type verification, validation and testing

VERSION

0.01.02 (Sun Jan 12 08:00:30 2003)

DESCRIPTION

This module supports types. Out of the ordinary it supports parameterised types (like
databases have i.e. VARCHAR(80) ). When you try to feed a typed variable against some
odd data, this module explains what he would have expected. It doesnt support casting (yet).

Backend was realized with Regexp::Common, Email::Valid and Business::CreditCard.

TYPES and FILTERS

perl -e "use Data::Type qw(:all); print catalog()" lists all supported types:

Data::Type 0.01.02 supports 28 types:

  BINARY             - binary code
  BOOL               - a true or false value
  CREDITCARD         - is one of a set of creditcard type (DINERS, BANKCARD, VISA, ..
  DATE               - a date (mysql or Date::Parse conform)
  DATETIME           - a date and time combination
  DK::YESNO          - a simple answer (mand, kvinde)
  EMAIL              - an email address
  ENUM               - a member of an enumeration
  GENDER             - a gender male, female
  HEX                - hexadecimal code
  INT                - an integer
  IP                 - an IP (V4, MAC) network address
  LONGTEXT           - text with a max length of 4294967295 (2^32 - 1) characters (..
  MEDIUMTEXT         - text with a max length of 16777215 (2^24 - 1) characters (al..
  NUM                - a number
  QUOTED             - a quoted string
  REAL               - a real
  REF                - a reference to a variable
  SET                - a set (can have a maximum of 64 members (mysql))
  TEXT               - blob with a max length of 65535 (2^16 - 1) characters (alias..
  TIME               - a time (mysql)
  TIMESTAMP          - a timestamp (mysql)
  TINYTEXT           - text with a max length of 255 (2^8 - 1) characters (alias my..
  URI                - an http uri
  VARCHAR            - a string with limited length of choice (default 60)
  WORD               - a word (without spaces)
  YEAR               - a year in 2- or 4-digit format
  YESNO              - a simple answer (yes, no)

And 4 filters:

  CHOMP              - chomps
  LC                 - lower cases
  STRIP              - strip
  UC                 - upper cases

GROUPED TOC

 Logic
  CREDITCARD, REF

 Database
   Logic
      ENUM, SET

   Time or Date related
      DATE, DATETIME, TIME, TIMESTAMP, YEAR

   String
      LONGTEXT, MEDIUMTEXT, TEXT, TINYTEXT

 W3C
   String
      BINARY, HEX

 Numeric
  BOOL, INT, NUM, REAL

 String
  DK::YESNO, EMAIL, GENDER, IP, QUOTED, URI, VARCHAR, WORD, YESNO


GROUP Database
These are types from the mysql database builtin types.

CREDITCARD

This type isn't tested at all and nobody should rely on it.

Supported are: 'Diners Club', 'Australian BankCard', 'VISA', 'Discover/Novus', 'JCB', 'MasterCard', 'Carte Blache', 'American Express'. 
They are parameterised as: DINERS, BANKCARD, VISA, DISCOVER, JCB, MASTERCARD, BLACHE, AMEX.

EXAMPLES

Look in the t directory (of the release) for examples. Here a very simple one:

use Data::Type qw(:all);
use Error qw(:try);

	try
	{
		verify( 'muenalan<at>cpan.org' , EMAIL );
		
		print "email valid";
	}
	catch Type::Exception with
	{
		print "this is not an email";
	};

KEYWORDS

data types, data manipulation, data patterns, form data, user input, tie

INSTALLATION

To install this module type the following:

   perl Makefile.PL
   make
   make test
   make install


CPAN PREREQUISITES
Class::Maker (0.05.10), Error (0.15), IO::Extended (0.05), Regexp::Common (1.20), Email::Valid (0.14), Tie::ListKeyedHash (0.41), Business::CreditCard (0.27), Iter (0), Date::Parse (2.23)

CONTRIBUTIONS

The author is happy to receive more types (formats) and add to this library. If you
have a algorithm/regex for validating it, the better. Just email me.

AUTHOR

Murat Ünalan, <murat.uenalan@cpan.org>

COPYRIGHT/LICENSE

(c) 2002 by Murat Ünalan. All rights reserved. Note: This program is
free software; you can redistribute it and/or modify it under the same
terms as perl itself


LAST CHANGES 0.01.02

  * Introduced various changes, thanks to https://rt.cpan.org/Ticket/Display.html?id=1930
    posted by Henrik Tougaard via RT

    - 'DATE' type now accepts parameters DATE( [ 'MYSQL','DATEPARSE' ] ) where MYSQL (default) is the
	mysql builtin data type behaviour and DATAPARSE leads to Data::Parse's str2time function use.
	- Introduced locale support (added empty package Data::Type::Locale)
	- separated localizable type parameters to methods, so they are overridable through inheriting
	localized types:
	
	Example Type::dk_yesno vs Type::yesno (snipped sourcecode):

	{
	package Type::yesno;

		our @ISA = qw(IType::String);
	
		sub info 
		{	
			my $this = shift;
					
			return sprintf q{a simple answer (%s)}, join( ', ', $this->choice ) ;
		}
	
		sub choice { qw(yes no) }
	
	package Type::dk_yesno;

		our @ISA = qw(Type::yesno);
		
		sub export { qw(DK::YESNO) };
			
		sub choice { qw(mand kvinde) }
	}
	
  * Export names for types are now accessible via 'export' method ( dk_yesno => DK::YESNO for instance ).
	
  * Types now have their own $VERSION
  
  * Some minor changes
    - rename IType:: info() to desc() for better distinguishing in toc(), because of a bug during
      @ISA traversal and IType:: identification (added _unique_ordered for using only unique desc's). 
    - toc() now lists also export alias's
    - regex's are now centralized and accessible via Regex::list( 'key' );
	
