They are not supported and trying to set them to an undefined value will trigger errors.
Signed-off-by: Francois Gouget fgouget@codeweavers.com --- testbot/lib/ObjectModel/EnumPropertyDescriptor.pm | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/testbot/lib/ObjectModel/EnumPropertyDescriptor.pm b/testbot/lib/ObjectModel/EnumPropertyDescriptor.pm index d5850698e..d8f0d391b 100644 --- a/testbot/lib/ObjectModel/EnumPropertyDescriptor.pm +++ b/testbot/lib/ObjectModel/EnumPropertyDescriptor.pm @@ -42,6 +42,10 @@ sub _initialize($$)
$self->{Class} = "Enum"; $self->{Values} = $Values; + if (!$self->{IsRequired}) + { + die "Optional enum properties are not supported\n"; + }
$self->SUPER::_initialize(); }
Signed-off-by: Francois Gouget fgouget@codeweavers.com --- testbot/lib/ObjectModel/EnumPropertyDescriptor.pm | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/testbot/lib/ObjectModel/EnumPropertyDescriptor.pm b/testbot/lib/ObjectModel/EnumPropertyDescriptor.pm index d8f0d391b..084667372 100644 --- a/testbot/lib/ObjectModel/EnumPropertyDescriptor.pm +++ b/testbot/lib/ObjectModel/EnumPropertyDescriptor.pm @@ -42,6 +42,7 @@ sub _initialize($$)
$self->{Class} = "Enum"; $self->{Values} = $Values; + map { $self->{Allowed}->{$_} = 1 } @{$Values}; if (!$self->{IsRequired}) { die "Optional enum properties are not supported\n"; @@ -68,18 +69,14 @@ sub ValidateValue($$$) { my ($self, $Value, $IsNew) = @_;
- if ($self->GetIsRequired()) - { - if (!$IsNew && (!defined($Value) || $Value eq "")) - { - return $self->GetDisplayName() . ": Must be entered"; - } - } + return undef if (defined $Value and $self->{Allowed}->{$Value});
- foreach my $V (@{$self->{Values}}) + if ($self->GetIsRequired() and !$IsNew and + (!defined $Value or $Value eq "")) { - return undef if ($V eq $Value); + return $self->GetDisplayName() . ": Must be entered"; } + return $self->GetDisplayName() . ": Is not valid"; }