feat(api): add validation to prevent duplicate accounts from being added

This commit is contained in:
Stevan Freeborn
2026-02-13 12:33:37 -06:00
parent 5d6ccaa6df
commit a4a0aca2b4
5 changed files with 226 additions and 1 deletions
+23
View File
@@ -0,0 +1,23 @@
namespace FiscalOS.API.Accounts.Add;
public record Request : IValidatableObject
{
public string PlaidInstitutionId { get; init; } = string.Empty;
public string PlaidAccountId { get; init; } = string.Empty;
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if (string.IsNullOrWhiteSpace(PlaidInstitutionId))
{
var fieldName = nameof(PlaidInstitutionId);
yield return new($"The {fieldName} field is required.", [fieldName]);
}
if (string.IsNullOrWhiteSpace(PlaidAccountId))
{
var fieldName = nameof(PlaidAccountId);
yield return new($"The {fieldName} field is required.", [fieldName]);
}
}
}