Observe the following class:
Java
public class UserProfile {
@NotNull(message = "Login must be not null.")
@Size(min = 3, message = "Login must contain at least three characters.")
private String login;
@NotNull(message = "Password must be not null.")
@Size(min = 5, message = "Password must contain at least five characters.")
private String password;
@NotNull(message = "Email must be not null.")
@Email(message = "Email is invalid.")
private String email;
// getters and setters
}Kotlin
class UserProfile(
@NotNull(message = "Login must be not null.")
@Size(min = 3, message = "Login must contain at least three characters.")
var login: String,
@NotNull(message = "Password must be not null.")
@Size(min = 5, message = "Password must contain at least five characters.")
var password: String,
@NotNull(message = "Email must be not null.")
@Email(message = "Email is invalid.")
var email: String
)And the corresponding REST Controller:
Java
@RestController
{1}
public class UserProfileController {
@GetMapping("/users/{login}")
ResponseEntity<String> getUserByLogin(
@PathVariable("login") {2} String login) {
return ResponseEntity.ok("User id is valid.");
}
@PostMapping("/users")
public ResponseEntity<String> addNewUserProfile(@RequestBody {3} {4} user) {
return ResponseEntity.ok("User info is valid.");
}
}Kotlin
@RestController
{1}
class UserProfileController {
@GetMapping("/users/{login}")
fun getUserByLogin(@PathVariable("login") {2} login: String): ResponseEntity<String> {
return ResponseEntity.ok("User id is valid.")
}
@PostMapping("/users")
fun addNewUserProfile(@RequestBody {3} user: {4}): ResponseEntity<String> {
return ResponseEntity.ok("User info is valid.")
}
}Match the missed UserProfileController annotations if:
loginpath variable of thegetUserByLoginmethod should contain at least 3 charactersthe request body of the
addNewUserProfilemethod should be validated