version bump for 1.9903
[gitmo/Moose.git] / lib / Moose / Meta / TypeConstraint / Enum.pm
index 8950068..54b5581 100644 (file)
@@ -6,10 +6,6 @@ use metaclass;
 
 use Moose::Util::TypeConstraints ();
 
-our $VERSION   = '0.94';
-$VERSION = eval $VERSION;
-our $AUTHORITY = 'cpan:STEVAN';
-
 use base 'Moose::Meta::TypeConstraint';
 
 __PACKAGE__->meta->add_attribute('values' => (
@@ -21,6 +17,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()
@@ -74,14 +86,12 @@ sub create_child_type {
 
 1;
 
+# ABSTRACT: Type constraint for enumerated values.
+
 __END__
 
 =pod
 
-=head1 NAME
-
-Moose::Meta::TypeConstraint::Enum - Type constraint for enumerated values.
-
 =head1 DESCRIPTION
 
 This class represents type constraints based on an enumerated list of
@@ -128,19 +138,6 @@ object!
 
 See L<Moose/BUGS> for details on reporting bugs.
 
-=head1 AUTHOR
-
-Yuval Kogman E<lt>nothingmuch@cpan.orgE<gt>
-
-=head1 COPYRIGHT AND LICENSE
-
-Copyright 2006-2010 by Infinity Interactive, Inc.
-
-L<http://www.iinteractive.com>
-
-This library is free software; you can redistribute it and/or modify
-it under the same terms as Perl itself.
-
 =cut