Verwaltung von Pflichtenheftstatus
[kivitendo-erp.git] / SL / DB / RequirementSpecAcceptanceStatus.pm
index ad50af8..e709f8d 100644 (file)
@@ -2,16 +2,23 @@ package SL::DB::RequirementSpecAcceptanceStatus;
 
 use strict;
 
+use List::MoreUtils qw(none);
+
 use SL::DB::MetaSetup::RequirementSpecAcceptanceStatus;
 use SL::DB::Manager::RequirementSpecAcceptanceStatus;
 use SL::DB::Helper::ActsAsList;
 use SL::Locale::String;
 
+our @valid_names = qw(accepted accepted_with_defects accepted_with_defects_to_be_fixed not_accepted);
+
 sub validate {
   my ($self) = @_;
 
   my @errors;
-  push @errors, t8('The description is missing.') if !$self->description;
+  push @errors, t8('The name is missing.')                     if !$self->name;
+  push @errors, t8('The name and description are not unique.') if  $self->get_first_conflicting('name', 'description');
+  push @errors, t8('The name is invalid.')                     if  none { $_ eq $self->name } @valid_names;
+  push @errors, t8('The description is missing.')              if !$self->description;
 
   return @errors;
 }