class PsuDataInInitialRequestValidator implements BusinessValidator<PsuIdData> {

    @Override
    public @NotNull ValidationResult validate(@NotNull PsuIdData psuIdData) {
        String psuId = psuIdData.getPsuId();
        if (aspspProfileService.isPsuInInitialRequestMandated() && StringUtils.isBlank(psuId)) {
            ErrorType errorType = errorTypeMapper.mapToErrorType(serviceTypeDiscoveryService.getServiceType(), FORMAT_ERROR.getCode());

            if (psuId == null) {
                log.info("PSU Data validation has failed: mandated PSU ID is null");
                return ValidationResult.invalid(errorType, FORMAT_ERROR_NO_PSU_ID);
            }

            log.info("PSU Data validation has failed: mandated PSU ID is blank");
            return ValidationResult.invalid(errorType, FORMAT_ERROR_PSU_ID_BLANK);
        }

        return ValidationResult.valid();
    }

}