Skip to content

GH-2531 - Map @Size on CharSequence to minLength/maxLength - #2537

Closed
kalayciburak wants to merge 1 commit into
spring-projects:mainfrom
kalayciburak:fix/hal-forms-size-charsequence-minlength
Closed

kalayciburak wants to merge 1 commit into
spring-projects:mainfrom
kalayciburak:fix/hal-forms-size-charsequence-minlength

Conversation

@kalayciburak

Copy link
Copy Markdown
Contributor

Summary

Fixes #2531.

jakarta.validation.constraints.Size constrains character/element count, not a numeric value range. For CharSequence properties this change:

  • maps @Size bounds to HAL-FORMS minLength / maxLength
  • stops forcing type: "range" so the default text input is used
  • leaves numeric min / max unset for those properties

Non-CharSequence @Size usage (and existing tests using @Size on non-text properties) keep the previous range + min/max behavior. Hibernate Validator @Length continues to contribute length bounds as before.

Test plan

  • ./mvnw -Dtest=PropertyUtilsTest test (22 tests, GREEN; Java 17)

@odrotbohm
odrotbohm force-pushed the main branch 3 times, most recently from 419490b to 04aac86 Compare August 21, 2026 12:18
…ngth

For CharSequence properties, jakarta.validation @SiZe constrains
character count. Surface that as HAL-FORMS minLength/maxLength and
keep the default text input type instead of forcing type=range with
numeric min/max. Non-CharSequence @SiZe usage is unchanged.

Signed-off-by: Burak KALAYCI <kalayciburak1996@gmail.com>
@kalayciburak
kalayciburak force-pushed the fix/hal-forms-size-charsequence-minlength branch from 2fdca21 to 3c933c3 Compare October 16, 2026 05:33
@odrotbohm

Copy link
Copy Markdown
Member

I've applied this and extended on it. Most important: skip the attribute rendering for default values and flip to the more appropriate attributes for collections, maps, and arrays.

@odrotbohm odrotbohm closed this Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@Size on String properties renders as HAL-FORMS type "range" with min/max instead of a text input with minLength/maxLength

2 participants