Add PIN validation to an existing Spring Boot card PATCH endpoint.
In an existing Spring Boot card application, add validation to the PATCH endpoint that updates a card's PIN. Rules: the PIN must be exactly four digits, numeric only, with no repeating digits anywhere (1213 is invalid even though the repeats are not adjacent), and a positive value, while preserving leading zeros.
The repository contains a card model with multiple fields, a controller, and a repository backed by H2 through JPA. The card model already stores the PIN as an int and the controller accepts it directly as an int parameter, so leading zeros require changing the representation to String across the controller, service/validation, card model and persistence mapping. Valid input updates the PIN preserving leading zeros; invalid input is rejected without modifying the stored card. Verify with tests covering the validation rules, leading-zero handling and unchanged state after rejected updates.
Format · Roughly one hour on HackerRank with an AI assistant and an existing Java Spring Boot + H2 + JPA repository.
Community answers
Related courses


