bump version to 1.19
[gitmo/Moose.git] / lib / Moose / Meta / TypeConstraint / Enum.pm
index aeab144..c28bc07 100644 (file)
@@ -6,7 +6,7 @@ use metaclass;
 
 use Moose::Util::TypeConstraints ();
 
-our $VERSION   = '0.82';
+our $VERSION   = '1.19';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
@@ -21,6 +21,22 @@ sub new {
 
     $args{parent} = Moose::Util::TypeConstraints::find_type_constraint('Str');
 
+    if ( scalar @{ $args{values} } < 2 ) {
+        require Moose;
+        Moose->throw_error("You must have at least two values to enumerate through");
+    }
+
+    for (@{ $args{values} }) {
+        if (!defined($_)) {
+            require Moose;
+            Moose->throw_error("Enum values must be strings, not undef");
+        }
+        elsif (ref($_)) {
+            require Moose;
+            Moose->throw_error("Enum values must be strings, not '$_'");
+        }
+    }
+
     my $self = $class->_new(\%args);
 
     $self->compile_type_constraint()
@@ -98,7 +114,7 @@ L<Moose::Meta::TypeConstraint>.
 
 =item B<< Moose::Meta::TypeConstraint::Enum->new(%options) >>
 
-This creates a new class type constraint based on the given
+This creates a new enum type constraint based on the given
 C<%options>.
 
 It takes the same options as its parent, with several
@@ -107,7 +123,7 @@ should be an array reference containing a list of valid string
 values. Second, it automatically sets the parent to the C<Str> type.
 
 Finally, it ignores any provided C<constraint> option. The constraint
-is generated automatically based on the provided C<values>
+is generated automatically based on the provided C<values>.
 
 =item B<< $constraint->values >>
 
@@ -126,9 +142,7 @@ object!
 
 =head1 BUGS
 
-All complex software has bugs lurking in it, and this module is no
-exception. If you find a bug please either email me, or add the bug
-to cpan-RT.
+See L<Moose/BUGS> for details on reporting bugs.
 
 =head1 AUTHOR
 
@@ -136,7 +150,7 @@ Yuval Kogman E<lt>nothingmuch@cpan.orgE<gt>
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright 2006-2009 by Infinity Interactive, Inc.
+Copyright 2006-2010 by Infinity Interactive, Inc.
 
 L<http://www.iinteractive.com>