@@ -30,8 +30,7 @@ private BasicAdapters() {}
30
30
case "NotBlank" -> new NotBlankAdapter (context .message (attributes ), groups );
31
31
case "NotEmpty" -> new NotEmptyAdapter (context .message (attributes ), groups );
32
32
case "Pattern" -> new PatternAdapter (context .message (attributes ), groups , attributes );
33
- case "Size" -> new SizeAdapter (context .message (attributes ), groups , attributes );
34
- case "Length" -> new LengthAdapter (context .message (attributes ), groups , attributes );
33
+ case "Size" , "Length" -> new SizeAdapter (context .message (attributes ), groups , attributes );
35
34
default -> null ;
36
35
};
37
36
@@ -113,37 +112,6 @@ public boolean validate(Object value, ValidationRequest req, String propertyName
113
112
}
114
113
}
115
114
116
- private static final class LengthAdapter implements ValidationAdapter <Object > {
117
-
118
- private final ValidationContext .Message message ;
119
- private final Set <Class <?>> groups ;
120
- private final int min ;
121
- private final int max ;
122
-
123
- LengthAdapter (ValidationContext .Message message , Set <Class <?>> groups , Map <String , Object > attributes ) {
124
- this .message = message ;
125
- this .groups = groups ;
126
- this .min = (int ) attributes .get ("min" );
127
- this .max = (int ) attributes .get ("max" );
128
- }
129
-
130
- @ Override
131
- public boolean validate (Object value , ValidationRequest req , String propertyName ) {
132
- if (!checkGroups (groups , req ) || value == null ) {
133
- return true ;
134
- }
135
-
136
- if (value instanceof final CharSequence sequence ) {
137
- final var len = sequence .length ();
138
- if (len > max || len < min ) {
139
- req .addViolation (message , propertyName );
140
- return false ;
141
- }
142
- }
143
- return true ;
144
- }
145
- }
146
-
147
115
private static final class NotBlankAdapter extends AbstractConstraintAdapter <CharSequence > {
148
116
149
117
NotBlankAdapter (ValidationContext .Message message , Set <Class <?>> groups ) {
0 commit comments