Skip to content

Commit 25b0d45

Browse files
committed
Validation
1 parent 50d6fe8 commit 25b0d45

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pkg/apis/restaurant/validation/validation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ func ValidatePizzaSpec(s *restaurant.PizzaSpec, fldPath *field.Path) field.Error
4242
if len(s.Toppings[i].Name) == 0 {
4343
allErrs = append(allErrs, field.Invalid(fldPath.Child("toppings").Index(i).Child("name"), s.Toppings[i].Name, "cannot be empty"))
4444
} else {
45-
prevNames[s.Toppings[i].Name] = true
4645
if prevNames[s.Toppings[i].Name] {
4746
allErrs = append(allErrs, field.Invalid(fldPath.Child("toppings").Index(i).Child("name"), s.Toppings[i].Name, "must be unique"))
4847
}
48+
prevNames[s.Toppings[i].Name] = true
4949
}
5050
}
5151

0 commit comments

Comments
 (0)