Are there any chances to figure out what countries require region code and what not through API OCC v2? It seems that it is not possible. And it turns out that I need to modify the client application each time I add regions to the without-region countries on the backend side.
It seems that it is a bad design.
I found that de.hybris.platform.acceleratorstorefrontcommons.forms.validation.AddressValidator has hardcoded checks. It seems that you have all the data to perform these checks without hardcoding.
protected void validateCountrySpecificFields(final AddressForm addressForm, final Errors errors)
{
final String isoCode = addressForm.getCountryIso();
if (isoCode != null)
{
switch (CountryCode.lookup(isoCode))
{
case CHINA:
validateStringField(addressForm.getTitleCode(), AddressField.TITLE, MAX_FIELD_LENGTH, errors);
validateFieldNotNull(addressForm.getRegionIso(), AddressField.REGION, errors);
break;
case CANADA:
validateStringField(addressForm.getTitleCode(), AddressField.TITLE, MAX_FIELD_LENGTH, errors);
validateFieldNotNull(addressForm.getRegionIso(), AddressField.REGION, errors);
break;
case USA:
validateStringField(addressForm.getTitleCode(), AddressField.TITLE, MAX_FIELD_LENGTH, errors);
validateFieldNotNull(addressForm.getRegionIso(), AddressField.REGION, errors);
break;
case JAPAN:
validateFieldNotNull(addressForm.getRegionIso(), AddressField.REGION, errors);
validateStringField(addressForm.getLine2(), AddressField.LINE2, MAX_FIELD_LENGTH, errors);
break;
default:
validateStringField(addressForm.getTitleCode(), AddressField.TITLE, MAX_FIELD_LENGTH, errors);
break;
}
}
}
It seems that it is a bad design too.