Skip to content

Fix Pattern message formatting with range quantifiers#36832

Open
Will-thom wants to merge 1 commit into
spring-projects:mainfrom
Will-thom:spring-21750-pattern-message
Open

Fix Pattern message formatting with range quantifiers#36832
Will-thom wants to merge 1 commit into
spring-projects:mainfrom
Will-thom:spring-21750-pattern-message

Conversation

@Will-thom
Copy link
Copy Markdown

Closes gh-21750

This updates Bean Validation error adaptation so Spring-style default messages such as {0} must match {regexp} can still be rendered with MessageFormat after Bean Validation has interpolated a constraint attribute containing regex braces, for example \d{1,3}.

The change escapes interpolated constraint attribute values before default-message rendering and stores the render decision in the serializable Spring error type so deserialized errors behave consistently.

Tests:

  • .\gradlew.bat --no-daemon :spring-context:test --tests org.springframework.validation.beanvalidation.SpringValidatorAdapterTests -x :spring-core:compileJava24Java

Note: local machine has JDK 21 only; Spring main currently requires a Java 25 toolchain, so the focused test was run with a temporary local toolchain override that was not committed, excluding the Java 24 multi-release compile task.

Signed-off-by: Will-thom <116388885+Will-thom@users.noreply.github.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label May 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged or decided on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@Pattern error message "{0}" is not resolved. [SPR-17217]

2 participants