Added limited goto expression syntax validator. Needs to do a bit more.

This commit is contained in:
Kaleb Murphy 2009-03-31 04:58:00 +00:00
parent 272283e75d
commit e515817053

View file

@ -1235,6 +1235,9 @@ sub validateSurvey{
if(! $self->validateGotoExpression($question,$goodTargets)){
push(@messages,"Section $s Question $q does not have a valid GOTO Expression target.");
}
if(! $self->validateExpressionSyntax($question)){
push(@messages,"Section $s Question $q does not appear to have valid GOTO Expression syntax.");
}
if($#{$question->{answers}} < 0){
push(@messages,"Section $s Question $q does not have any answers.");
}
@ -1265,6 +1268,16 @@ sub validateSurvey{
return \@messages;
}
sub validateExpressionSyntax{
my $self = shift;
my $object = shift;
if($object->{gotoExpression} =~ /\w/){
my ( $target, $rest ) = $object->{gotoExpression} =~ /\s* ([^:]+?) \s* : \s* (.*)/x;
return 0 if(! defined $target or ! defined $rest);
}
return 1;
}
sub validateInfLoop{
my $self = shift;
my $object = shift;