Skip to content

Commit 6d29f85

Browse files
KrivenkoAlexanderphp-coder
authored andcommitted
fix(validation): price and alternative price must be in different currencies on series sale form.
Fix #504
1 parent 175a4bd commit 6d29f85

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

src/main/java/ru/mystamps/web/feature/series/sale/AddSeriesSalesForm.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,17 @@
3333
import java.util.Date;
3434

3535
// @todo #503 Add integration test to ensure that seller and buyer are different
36+
// @todo #504 Add integration test to ensure that price and alternative price are different
3637
@Getter
3738
@Setter
38-
@FieldsMismatch(first = "sellerId", second = "buyerId", message = "{seller.buyer.match}")
39+
@FieldsMismatch.List({
40+
@FieldsMismatch(
41+
first = "sellerId", second = "buyerId", message = "{seller.buyer.match}"
42+
),
43+
@FieldsMismatch(
44+
first = "currency", second = "altCurrency", message = "{currencies.prices.match}"
45+
)
46+
})
3947
public class AddSeriesSalesForm implements AddSeriesSalesDto {
4048

4149
@DateTimeFormat(pattern = "dd.MM.yyyy")
@@ -70,5 +78,5 @@ public class AddSeriesSalesForm implements AddSeriesSalesDto {
7078
})
7179
public interface UrlChecks {
7280
}
73-
81+
7482
}

src/main/java/ru/mystamps/web/support/beanvalidation/FieldsMismatch.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,15 @@
3838

3939
String first();
4040
String second();
41+
42+
/**
43+
* Allow to place several {@code @FieldsMismatch} annotations on the same element.
44+
*/
45+
@Target({TYPE, ANNOTATION_TYPE })
46+
@Retention(RUNTIME)
47+
@Documented
48+
@interface List {
49+
FieldsMismatch[] value();
50+
}
51+
4152
}

src/main/resources/ru/mystamps/i18n/ValidationMessages.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ login.repetition_chars = Login must not contain repetition of hyphen, dot or und
4949
password.mismatch = Password mismatch
5050
password.login.match = Password and login must be different
5151
seller.buyer.match = Seller and buyer must be different
52+
currencies.prices.match = Price and alternative price must be in a different currencies
5253

5354
name.invalid = Name must consist only letters, hyphen or spaces
5455

src/main/resources/ru/mystamps/i18n/ValidationMessages_ru.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ login.repetition_chars = Логин не должен содержать пов
4949
password.mismatch = Пароли не совпадают
5050
password.login.match = Пароль и логин не должны совпадать
5151
seller.buyer.match = Продавец и покупатель не должны совпадать
52+
currencies.prices.match = Цена и альтернативная цена должны быть в различных валютах
5253

5354
name.invalid = Имя может состоять только из букв, дефиса или пробелов
5455

0 commit comments

Comments
 (0)