Class CountryValidation
java.lang.Object
api.mpba.rastvdmy.service.validator.CountryValidation
- All Implemented Interfaces:
ValidationStrategy
A strategy for validating a country by checking if a country exists by checking against an external REST API.
-
Constructor Summary
ConstructorDescriptionCountryValidation
(org.springframework.web.client.RestTemplate restTemplate) Constructor for CountryValidation. -
Method Summary
-
Constructor Details
-
CountryValidation
public CountryValidation(org.springframework.web.client.RestTemplate restTemplate) Constructor for CountryValidation.- Parameters:
restTemplate
- The RestTemplate to use for making HTTP requests.
-
-
Method Details
-
validate
Validates the given country name.- Specified by:
validate
in interfaceValidationStrategy
- Parameters:
countryName
- The name of the country to validate.- Throws:
ApplicationException
- if the country does not exist.
-