Permalink
Browse files

Fix relations and release status.

No need to support old CPAN stuff.

Also, document undocumented validator methods.
  • Loading branch information...
1 parent 45593e5 commit c16110c63fa6de5f4c21566cbf49a986029335bb @theory theory committed May 25, 2011
Showing with 32 additions and 13 deletions.
  1. +32 −13 lib/PGXN/Meta/Validator.pm
View
45 lib/PGXN/Meta/Validator.pm
@@ -344,6 +344,10 @@ sub check_listormap {
=over
+=item * anything($self,$key,$value)
+
+Any value is valid, so this function always returns true.
+
=item * header($self,$key,$value)
Validates that the header is valid.
@@ -354,6 +358,10 @@ Note: No longer used as we now read the data structure, not the file.
Validates that a given value is in an acceptable URL format
+=item * email($self,$key,$value)
+
+Validates that a given value is in an acceptable EMAIL format
+
=item * urlspec($self,$key,$value)
Validates that the URL to a META specification is a known one.
@@ -368,11 +376,30 @@ defined.
Validates that a string exists for the given key.
+=item * lc_string($self,$key,$value)
+
+Validates that a string exists for the given key and contains only lowercase
+characters.
+
=item * file($self,$key,$value)
Validate that a file is passed for the given key. This may be made more
thorough in the future. For now it acts like \&string.
+=item * phase($self,$key,$value)
+
+Validate that a prereq phase is one of "configure", "build", "test",
+"runtime", or "develop".
+
+=item * relation($self,$key,$value)
+
+Validate that a prereq relation is one of "requires", "recommends", or
+"suggests".
+
+=item * release_status($self,$key,$value)
+
+Validate that release status is one of "stable", "testing", or "unstable".
+
=item * exversion($self,$key,$value)
Validates a list of versions, e.g. '<= 5, >=2, ==3, !=4, >1, <6, 0'.
@@ -430,19 +457,11 @@ sub header {
sub release_status {
my ($self,$key,$value) = @_;
- if(defined $value) {
- my $version = $self->{data}{version} || '';
- if ( $version =~ /_/ ) {
- return 1 if ( $value =~ /\A(?:testing|unstable)\z/ );
- $self->_error( "'$value' for '$key' is invalid for version '$version'" );
- }
- else {
- return 1 if ( $value =~ /\A(?:stable|testing|unstable)\z/ );
+ if (defined $value) {
+ return 1 if $value =~ /\A(?:(?:un)?stable|testing)\z/;
$self->_error( "'$value' for '$key' is invalid" );
- }
- }
- else {
- $self->_error( "'$key' is not defined" );
+ } else {
+ $self->_error( "'$key' is not defined" );
}
return 0;
}
@@ -687,7 +706,7 @@ sub phase {
return 0;
}
-my @valid_relations = qw/ requires recommends suggests conflicts /;
+my @valid_relations = qw/ requires recommends suggests /;
sub relation {
my ($self,$key) = @_;
if(defined $key) {

0 comments on commit c16110c

Please sign in to comment.