Files
mic-check/src/api/MicCheck.Api/Organizations/InviteUserRequest.cs
James Wampler bdc85a1f3a Remove FluentValidation dependency, use plain .NET validation
Replace AbstractValidator-based request validators with a small
IModelValidator<T>/ValidationResult pattern (ported from BuyEngine's
Common namespace), wired into the MVC pipeline via a
ModelValidationActionFilter so controllers and response shape are
unaffected. Also copy over the Guard precondition helper.
2026-07-05 21:57:35 -07:00

24 lines
766 B
C#
Executable File

using MicCheck.Api.Common.Validation;
namespace MicCheck.Api.Organizations;
public record InviteUserRequest(int UserId, string Role);
public class InviteUserRequestValidator : IModelValidator<InviteUserRequest>
{
public ValidationResult Validate(InviteUserRequest model)
{
var result = new ValidationResult();
if (model.UserId <= 0)
result.AddError(nameof(model.UserId), "'User Id' must be greater than 0.");
if (string.IsNullOrEmpty(model.Role))
result.AddError(nameof(model.Role), "'Role' must not be empty.");
else if (!Enum.TryParse<OrganizationRole>(model.Role, true, out _))
result.AddError(nameof(model.Role), "Role must be 'User' or 'Admin'.");
return result;
}
}