Skip to content

Commit 001b34f

Browse files
n583wxdh0jphp-coder
authored andcommitted
/country/add: deny "add" and "list" as country names.
Fix #510
1 parent c456135 commit 001b34f

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

src/main/java/ru/mystamps/web/model/AddCountryForm.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import lombok.Setter;
2828

2929
import ru.mystamps.web.service.dto.AddCountryDto;
30+
import ru.mystamps.web.validation.jsr303.DenyValues;
3031
import ru.mystamps.web.validation.jsr303.UniqueCountryName;
3132
import ru.mystamps.web.validation.jsr303.UniqueCountryName.Lang;
3233
import ru.mystamps.web.validation.jsr303.UniqueCountrySlug;
@@ -48,7 +49,8 @@
4849
Group.Level4.class,
4950
Group.Level5.class,
5051
Group.Level6.class,
51-
Group.Level7.class
52+
Group.Level7.class,
53+
Group.Level8.class
5254
})
5355
public class AddCountryForm implements AddCountryDto {
5456

@@ -82,8 +84,9 @@ public class AddCountryForm implements AddCountryDto {
8284
groups = Group.Level5.class
8385
)
8486
})
85-
@UniqueCountryName(lang = Lang.EN, groups = Group.Level6.class)
86-
@UniqueCountrySlug(groups = Group.Level7.class)
87+
@DenyValues(value = {"add", "list"}, groups = Group.Level6.class)
88+
@UniqueCountryName(lang = Lang.EN, groups = Group.Level7.class)
89+
@UniqueCountrySlug(groups = Group.Level8.class)
8790
private String name;
8891

8992
@Size.List({
@@ -115,7 +118,7 @@ public class AddCountryForm implements AddCountryDto {
115118
groups = Group.Level5.class
116119
)
117120
})
118-
@UniqueCountryName(lang = Lang.RU, groups = Group.Level6.class)
121+
@UniqueCountryName(lang = Lang.RU, groups = Group.Level7.class)
119122
private String nameRu;
120123

121124
}

src/test/robotframework/country/creation/validation.robot

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,19 @@ Create country with non-existing name but existing slug
7979
Clear Element Text id=nameRu
8080
Submit Form id=add-country-form
8181
Element Text Should Be id=name.errors Country with similar name already exists
82+
83+
Create country with forbidden names
84+
[Documentation] Verify validation of forbidden names
85+
# Open a page again to have a clean state (nameRu field has an invalid value)
86+
Go To ${SITE_URL}/country/add
87+
# 'add' is a forbidden value
88+
Input Text id=name add
89+
Submit Form id=add-country-form
90+
Element Text Should Be id=name.errors Invalid value
91+
# 'list' is a forbidden value
92+
Input Text id=name list
93+
Submit Form id=add-country-form
94+
Element Text Should Be id=name.errors Invalid value
8295

8396
*** Keywords ***
8497
Before Test Suite

0 commit comments

Comments
 (0)