This library enables validating beans with Bean Validation using Retrofit 2 thanks to its converter feature.
With Maven :
<dependency>
<groupId>io.github.ghusta.retrofit2</groupId>
<artifactId>retrofit-converter-validation</artifactId>
<version>1.0.0</version>
</dependency>
For example :
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://api.github.com/")
.addConverterFactory(ValidationConverterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.build();
Note
|
The declaration order of converters is important. ValidationConverterFactory must be declared before JSON converters.
|