Skip to content

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

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

GH-2531 - Map @Size on CharSequence to minLength/maxLength#2537
kalayciburak wants to merge 1 commit into
spring-projects:mainfrom
kalayciburak:fix/hal-forms-size-charsequence-minlength

Conversation

@kalayciburak

Copy link
Copy Markdown

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)

…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>
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

1 participant