private void AccountValidations(CreateAccountPayload payload) {
if (string.IsNullOrEmpty(payload.Note)) {
throw new ArgumentException($ "Note cannot be empty");
}
if (string.IsNullOrEmpty(payload.AccountName)) {
throw new ArgumentException($ "Account Name cnnot be Empty");
}
if (string.IsNullOrEmpty(payload.Type)) {
throw new ArgumentException($ "Account Type cnnot be Empty");
}
}
I want all the exception messages at once, eg: In the payload object if I don't provide AccountName
and Note
. It should report me both Note cannot be empty and Account Name can not be Empty How can I do that?
I thought of making a List of all these messages and then throw a Agregateexception
. How can I do this?