Skip to content

Commit 23964e1

Browse files
committed
Don't get confused with default message
1 parent 49c9831 commit 23964e1

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/main/java/org/primeframework/mvc/content/json/BaseJacksonContentHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ private void addFieldError(InvalidFormatException e) {
212212
Matcher matchesEnumNotValidValue = invalidEnumerationValue.matcher(messageText);
213213
String message = null;
214214
if (matchesEnumNotValidValue.matches() && matchesEnumNotValidValue.groupCount() == 2) {
215-
code = "[invalid]%s".formatted(field);
215+
code = "[invalidEnum]%s".formatted(field);
216216
// if we have an invalid enum value, provide a better message
217217
String possibleValues = matchesEnumNotValidValue.group(2);
218218
String valueUsed = matchesEnumNotValidValue.group(1);

src/test/java/org/primeframework/mvc/content/json/JacksonContentHandlerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,15 @@ public void enum_values(boolean nested) throws IOException {
103103
request.setContentType("application/json");
104104

105105
MessageProvider messageProvider = createStrictMock(MessageProvider.class);
106-
expect(messageProvider.getMessage(eq(nested ? "[invalid]nested.fruit" : "[invalid]fruit"),
106+
expect(messageProvider.getMessage(eq(nested ? "[invalidEnum]nested.fruit" : "[invalidEnum]fruit"),
107107
eq(nested ? "bar" : "foo"),
108108
eq("Apple, Orange"))).andReturn("Bad value");
109109
replay(messageProvider);
110110

111111
MessageStore messageStore = createStrictMock(MessageStore.class);
112112
messageStore.add(new SimpleFieldMessage(MessageType.ERROR,
113113
nested ? "nested.fruit" : "fruit",
114-
nested ? "[invalid]nested.fruit" : "[invalid]fruit",
114+
nested ? "[invalidEnum]nested.fruit" : "[invalidEnum]fruit",
115115
"Bad value"));
116116
replay(messageStore);
117117

0 commit comments

Comments
 (0)