Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 532641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:25:35+00:00 2026-05-13T09:25:35+00:00

I am currently working on a project where I have a BankAccount entity for

  • 0

I am currently working on a project where I have a BankAccount entity for some other entity.

Each bank account as a reference to a bank entity, an account number and optionally an IBAN.

Now since an IBAN can be validated, how can I ensure that when the IBAN is set for an account is valid. What would be a clean architectural approach? I currently have a domain layer without any reference to any other layer and I like this clean approach (I was inspired by Eric Evans DDD). Fortunately the IBAN validation can be performed without accessing any outside system so in this case I could have something like

puclic class BankAccount
{
  public string Iban
  {
     set { // validation logic here }
  }
}

But now I was thinking what approach I would use if the IBAN validation requires an SQL server check for example, or an external dll. How would I implement that. Would I create an IBAN value object which is passed to a service, that decides whether the IBAN is valid or not and after that set it to the BankAccount entity?
Or would I create a factory which is allowed to instanstiate IBANs and performs validation before?

Thanks for your help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T09:25:36+00:00Added an answer on May 13, 2026 at 9:25 am

    I would use some form of Inversion Of Control.

    To be specific, I would have an interface called IIBANValidator. The various means of validating the IBAN should implement that interface. For example:

    interface IBANValidator {
        Boolean Validate(string iban);
    }
    
    class SqlBanValidator : IBANValidator {
    
        public bool Validate(string iban) {
            // make the sql call to validate..
            throw new NotImplementedException();
        }
    
    }
    

    Then, I would have a method in my BankAccount class which accepted an object that implements IIBANValidator and the IBAN number and was structured like (not optimized by any stretch):

    Boolean SetIBAN(IIBANValidator validator, String iban) {
      Boolean result = false;
      if (validator.Validate(iban)) {
        Iban = iban;
        result = true;
      }
    
      return result;
    }
    

    At this point your BankAccount class would not have to have a dependency on your validators, you could swap them out at will, and ultimately it’s very clean.

    The final code would look something like:

    BankAccount account = new BankAccount();
    account.SetIBAN(new SqlBanValidator(), "my iban code");
    

    Obviously at runtime you could pass any validator instance you wanted.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently working on grails project. I have created eight different plugins. Each
I have a MVC 4 project I am currently working on and need some
I'm currently working on project with Haskell, and have found myself some trouble. I'm
I'm currently working on a project about social networking, where I have some problems
I am currently working on a project where I have code that looks like
I am currently working on a project about calculations.I have done the main part
I am currently working on android project where I want to have a text
I am currently working on an android project and I have an activity, lets
Im currently working on a grizzly, spring and jersey project and i have encountered:
Hello Ruby/Rails/Merb developers! Im currently working on a web project that will have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.