Endpoint
Changes the name of an existing player. The new name must be valid and follow validation constraints.Path Parameters
The unique identifier (UUID) of the player whose name you want to change
Request Body
The new name for the player. Must be between 1-30 characters (after trimming whitespace) and not blank.
Validation Rules
The player name must satisfy the following constraints:Not Blank
Not Blank
The name cannot be empty or consist only of whitespace. Leading and trailing whitespace is automatically trimmed.
PlayerName.java
Maximum Length: 30 characters
Maximum Length: 30 characters
After trimming whitespace, the name must not exceed 30 characters.
PlayerName.java
Automatic Trimming
Automatic Trimming
Leading and trailing whitespace is automatically removed from the name.
PlayerName.java
Response
The unique identifier of the player
The player’s new name (after trimming)
Number of games won by the player
Number of games lost by the player
Examples
Successful Name Change
Trimming Whitespace
Error Responses
400 Bad Request - Blank Name
400 Bad Request - Name Too Long
404 Not Found - Player Doesn’t Exist
Implementation Details
The endpoint follows a clean architecture pattern with domain-driven design:Validate Request
The request is validated at the controller level using Jakarta Bean Validation annotations:
ChangePlayerNameRequest.java
Create Domain Object
The use case creates a
PlayerName value object, which performs domain-level validation:ChangePlayerNameUseCase.java
The Player aggregate is immutable, so the
rename() method returns a new Player instance rather than modifying the existing one.Related Endpoints
Player Overview
Learn about the Player aggregate
View Rankings
See all players ranked by score