0
0
Spring Bootframework~10 mins

@Size for length constraints in Spring Boot - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to set a minimum length of 5 characters using @Size.

Spring Boot
@Size(min = [1])
private String username;
Drag options to blanks, or click blank then click option'
A3
B10
C0
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Using max instead of min for minimum length.
Setting the value too low or zero when a minimum is needed.
2fill in blank
medium

Complete the code to set a maximum length of 20 characters using @Size.

Spring Boot
@Size(max = [1])
private String password;
Drag options to blanks, or click blank then click option'
A10
B20
C30
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing min and max attributes.
Setting a maximum length smaller than the minimum length.
3fill in blank
hard

Fix the error in the @Size annotation to require a length between 3 and 15 characters.

Spring Boot
@Size(min = 3, max = [1])
private String nickname;
Drag options to blanks, or click blank then click option'
A15
B5
C10
D20
Attempts:
3 left
💡 Hint
Common Mistakes
Setting max less than min causing validation errors.
Using incorrect numbers that don't match the requirement.
4fill in blank
hard

Fill both blanks to require a string length between 8 and 25 characters.

Spring Boot
@Size(min = [1], max = [2])
private String description;
Drag options to blanks, or click blank then click option'
A8
B10
C25
D30
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping min and max values.
Choosing numbers outside the required range.
5fill in blank
hard

Fill all three blanks to require a string length between 4 and 12 characters and add a custom error message.

Spring Boot
@Size(min = [1], max = [2], message = "[3]")
private String title;
Drag options to blanks, or click blank then click option'
A4
B12
CLength must be between 4 and 12 characters
DLength should be at least 5
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to add the message attribute.
Using incorrect numbers for min or max.
Writing a message that does not match the length constraints.