class AccountReferenceAccessValidator {

    public ValidationResult validate(AisConsent aisConsent, List<AccountReference> references, String accountId, AisConsentRequestType consentRequestType) {
        if (AisConsentRequestType.GLOBAL == consentRequestType) {
            return ValidationResult.valid();
        }

        if (isConsentForAllAvailableAccounts(aisConsent)
                || !isValidAccountByAccess(accountId, references)) {
            return ValidationResult.invalid(ErrorType.AIS_401, CONSENT_INVALID);
        }

        return ValidationResult.valid();
    }

}