Hi all,
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!