Skip to content

Commit 740d210

Browse files
committed
CountryServiceImpl.add(): add check for empty string in addition to nullness.
1 parent 9749b5c commit 740d210

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/main/java/ru/mystamps/web/service/CountryServiceImpl.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.springframework.security.access.prepost.PreAuthorize;
2424
import org.springframework.transaction.annotation.Transactional;
2525

26+
import org.apache.commons.lang3.StringUtils;
2627
import org.apache.commons.lang3.Validate;
2728

2829
import org.slf4j.Logger;
@@ -58,9 +59,12 @@ public Country add(AddCountryDto dto, User user) {
5859
Country country = new Country();
5960
country.setName(dto.getName());
6061
country.setNameRu(dto.getNameRu());
61-
62+
6263
String slug = SlugUtils.slugify(dto.getName());
63-
Validate.isTrue(slug != null, "Slug for string '%s' is null", dto.getName());
64+
Validate.isTrue(
65+
StringUtils.isNotEmpty(slug),
66+
"Slug for string '%s' must be non empty", dto.getName()
67+
);
6468
country.setSlug(slug);
6569

6670
Date now = new Date();

0 commit comments

Comments
 (0)