Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ private void addFieldError(InvalidFormatException e) {
Matcher matchesEnumNotValidValue = invalidEnumerationValue.matcher(messageText);
String message = null;
if (matchesEnumNotValidValue.matches() && matchesEnumNotValidValue.groupCount() == 2) {
code = "[invalid]%s".formatted(field);
code = "[invalidEnum]%s".formatted(field);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

invalidEnum feels a little off to me, but I can't put my finger on why. Too Java focused? Too much detail?

Is there something more generic like invalidOption or invalidSelection that would work?

If no one else has an issue, we can keep it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Push includes this change. Arguably not a patch release. In practice, not sure how much matters.

// if we have an invalid enum value, provide a better message
String possibleValues = matchesEnumNotValidValue.group(2);
String valueUsed = matchesEnumNotValidValue.group(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ public void enum_values(boolean nested) throws IOException {
request.setContentType("application/json");

MessageProvider messageProvider = createStrictMock(MessageProvider.class);
expect(messageProvider.getMessage(eq(nested ? "[invalid]nested.fruit" : "[invalid]fruit"),
expect(messageProvider.getMessage(eq(nested ? "[invalidEnum]nested.fruit" : "[invalidEnum]fruit"),
eq(nested ? "bar" : "foo"),
eq("Apple, Orange"))).andReturn("Bad value");
replay(messageProvider);

MessageStore messageStore = createStrictMock(MessageStore.class);
messageStore.add(new SimpleFieldMessage(MessageType.ERROR,
nested ? "nested.fruit" : "fruit",
nested ? "[invalid]nested.fruit" : "[invalid]fruit",
nested ? "[invalidEnum]nested.fruit" : "[invalidEnum]fruit",
"Bad value"));
replay(messageStore);

Expand Down