## Summary - Remove FluentValidation dependency; replace with plain IModelValidator<T>/ValidationResult pattern (ported from BuyEngine's Guard/validation approach), wired via a ModelValidationActionFilter - Move FeatureUsage code into MicCheck.Api.Features.Usage namespace - Convert logic-free data classes to records per CLAUDE.md (WebhookEvent, FeatureStateResult, ProjectPermissionRequirement, AuditLog, Tag, FeatureUsageDaily) - Extract IAuditService interface, drop virtual-method mock seam on AuditService - Split Program.cs DI registrations into per-namespace DependencyRegistration classes ## Test plan - [x] dotnet build (API + tests) clean - [x] dotnet test MicCheck.Api.Tests.Unit — 646/646 passing - [x] pre-push hook (full solution build/test + admin build) passed Co-authored-by: miccheck-ci <ci@miccheck.local> Reviewed-on: #7
24 lines
779 B
C#
Executable File
24 lines
779 B
C#
Executable File
using MicCheck.Api.Common.Validation;
|
|
|
|
namespace MicCheck.Api.Projects;
|
|
|
|
public record CreateProjectRequest(string Name, int OrganizationId);
|
|
|
|
public class CreateProjectRequestValidator : IModelValidator<CreateProjectRequest>
|
|
{
|
|
public ValidationResult Validate(CreateProjectRequest model)
|
|
{
|
|
var result = new ValidationResult();
|
|
|
|
if (string.IsNullOrEmpty(model.Name))
|
|
result.AddError(nameof(model.Name), "'Name' must not be empty.");
|
|
else if (model.Name.Length > 200)
|
|
result.AddError(nameof(model.Name), "'Name' must be 200 characters or fewer.");
|
|
|
|
if (model.OrganizationId <= 0)
|
|
result.AddError(nameof(model.OrganizationId), "'Organization Id' must be greater than 0.");
|
|
|
|
return result;
|
|
}
|
|
}
|