---
# System prepended metadata

title: ATLAS - Rest API with Spring boot (part 4)

---

# ATLAS - Rest API with Spring boot (part 4)

## Context
See [part 1](https://hackmd.io/OAcft3gBT0SkV-SF__rGeg) for details on the context.

## Prerequisites
Finish [part 3](https://hackmd.io/OaA8nHOMTKih9-rM7YVEsA).

## Specifications

Add the validation starter to the project's dependencies (pom.xml).

Refactor with DTO (Data Transfer Objects) and some validation constraints.

Validation constraints docs: [Jakarta Bean Validation](https://docs.jboss.org/hibernate/beanvalidation/spec/2.0/api/javax/validation/constraints/package-summary.html).

### Data Transfer Objects
Implement seperate DTO in order to create, fully update and partially update a capital, a continent, a country and a river. The controller must now declare a DTO instead of an entity in the related routes.

### Constraints

#### Country
- Iso code 2: required, exactly 2 letters
- Iso code 3: optional, exactly 3 letters
- Name: required, at least one non-whitespace character, maximum 150 chars
- Area: optional, positive
- Population: required, positive
- Official language: required, at least one non-whitespace character, maximum 75 chars

#### Capital
- Name: required, at least one non-whitespace character, maximum 150 chars
- Area: optional, positive
- Population: required, positive

#### Continent
- Name: required, at least one non-whitespace character, maximum 100 chars
- Area: optional, positive

#### River
- Name: required, at least one non-whitespace character, maximum 50 chars
- Length: optional, positive
- Source: required, at least one non-whitespace character, maximum 100 chars
- Mouth: required, at least one non-whitespace character, maximum 100 chars