diff --git a/src/FiscalOS.API/Login/Request.cs b/src/FiscalOS.API/Login/Request.cs index d793832..4f1ebf3 100644 --- a/src/FiscalOS.API/Login/Request.cs +++ b/src/FiscalOS.API/Login/Request.cs @@ -1,8 +1,21 @@ + namespace FiscalOS.API.Login; -public record LoginRequest( - [Required] - string Username, - [Required] - string Password -); \ No newline at end of file +public record LoginRequest : IValidatableObject +{ + public string Username { get; init; } = string.Empty; + public string Password { get; init; } = string.Empty; + + public IEnumerable Validate(ValidationContext validationContext) + { + if (string.IsNullOrWhiteSpace(Username)) + { + yield return new("The Username field is required.", [nameof(Username)]); + } + + if (string.IsNullOrWhiteSpace(Password)) + { + yield return new("The Password field is required.", [nameof(Password)]); + } + } +} \ No newline at end of file