From: John Napiorkowski Date: Fri, 25 Jun 2010 01:30:01 +0000 (-0400) Subject: fixed readme X-Git-Tag: 0.03~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMooseX-Dependent.git;a=commitdiff_plain;h=4a786d1f20fe2bb0d37e91c78c26c9da40821cef fixed readme --- diff --git a/README b/README index 4f5099d..7348c28 100644 --- a/README +++ b/README @@ -13,7 +13,7 @@ SYNOPSIS ## Create a type constraint that is a string but parameterizes an integer ## that is used as a maximum length constraint on that string, similar to - ## an SQL Varchar type. + ## a SQL Varchar database type. subtype Varchar, as Parameterizable[Str,Int], @@ -41,13 +41,13 @@ SYNOPSIS ## Dies with an invalid constraint for 'varchar_five' my $object2 = __PACKAGE__->new( - varchar_five => '12345678', + varchar_five => '12345678', ## too long! varchar_ten => '123456789', ); ## varchar_five coerces as expected my $object3 = __PACKAGE__->new( - varchar_five => [qw/aa bb/], + varchar_five => [qw/aa bb/], ## coerces to "aabb" varchar_ten => '123456789', ); @@ -56,13 +56,19 @@ SYNOPSIS DESCRIPTION A MooseX::Types library for creating parameterizable types. A parameterizable type constraint for all intents and uses is a subclass - of a parent type, but adds a secondary type parameter which is available - to constraint callbacks (such as inside the 'where' clause) or in the - coercions. + of a parent type, but adds additional type parameters which are + available to constraint callbacks (such as inside the 'where' clause of + a type constraint definition) or in the coercions. - This allows you to create a type that has additional runtime advice, - such as a set of numbers within which another number must be unique, or - allowable ranges for a integer, such as in: + If you have Moose experience, you probably are familiar with the builtin + parameterizable type constraints 'ArrayRef' and 'HashRef'. This type + constraint lets you generate your own versions of parameterized + constraints that work similarly. See Moose::Util::TypeConstraints for + more. + + Using this type constraint, you can generate new type constraints that + have additional runtime advice, such as being able to specify maximum + and minimum values for an Int (integer) type constraint: subtype Range, as Dict[max=>Int, min=>Int], @@ -82,8 +88,11 @@ DESCRIPTION RangedInt([{min=>10,max=>100}])->check(50); ## OK RangedInt([{min=>50, max=>75}])->check(99); ## Not OK, 99 exceeds max - This throws a hard Moose exception. You'll need to capture it in an eval - or related exception catching system (see TryCatch or .) + The type parameter must be valid against the type constraint given. If + you pass an invalid value this throws a hard Moose exception. You'll + need to capture it in an eval or related exception catching system (see + TryCatch or .) For example the following would throw a hard + error (and not just return false) RangedInt([{min=>99, max=>10}])->check(10); ## Not OK, not a valid Range! @@ -254,7 +263,7 @@ DESCRIPTION }; Recursion - TBD + TBD - Need more tests. TYPE CONSTRAINTS This type library defines the following constraints.