Skip to content

Commit e5ba721

Browse files
committed
Add minLenght and maxLenght support to TextField
Add minLenght and maxLenght support to TextField
1 parent 4221248 commit e5ba721

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/main/java/io/asfjava/ui/core/form/TextField.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515

1616
String description() default "";
1717

18+
int minLenght() default 0;
19+
20+
int maxLenght() default Integer.MAX_VALUE;
21+
1822
String fieldAddonLeft() default"";
1923

2024
String fieldAddonRight() default"";

src/main/java/io/asfjava/ui/core/schema/decorators/TextFieldSchemaDecorator.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ public void customizeSchema(BeanProperty property, JsonSchema jsonschema) {
1818
if (annotation.pattern() != null) {
1919
((StringSchema) jsonschema).setPattern(annotation.pattern());
2020
}
21+
if (annotation.minLenght() != 0) {
22+
((StringSchema) jsonschema).setMinLength(annotation.minLenght());
23+
}
24+
if (annotation.maxLenght() != Integer.MAX_VALUE) {
25+
((StringSchema) jsonschema).setMaxLength(annotation.maxLenght());
26+
}
2127
}
2228
}
2329

0 commit comments

Comments
 (0)