class AccountAccessMultipleAccountsValidator {

    public ValidationResult validate(AisConsent aisConsent, boolean withBalance) {
        if (withBalance && aisConsent.isConsentForDedicatedAccounts()) {
            AccountAccess access = aisConsent.getAccess();
            return validateAccountReferenceSize(access.getAccounts(), access.getBalances())
                       ? ValidationResult.invalid(ErrorType.AIS_401, CONSENT_INVALID)
                       : ValidationResult.valid();
        }

        return ValidationResult.valid();
    }

}