using System.ComponentModel.DataAnnotations; namespace T120B165_ImgBoard.Dtos.Post; public record CreatePostDto(string Title, [Required] string Description, [Required] List Tags, [Required] string FileName, [Required] string FileMimeType, [Required] [Range(0, long.MaxValue, ErrorMessage = "The {0} must be a valid number and at least {1}.")] long? FileSize ); public record EditPostDto(string? Title, string? Description, List? Tags): IValidatableObject { public IEnumerable Validate(ValidationContext validationContext) { var allEmpty = string.IsNullOrWhiteSpace(Title) && string.IsNullOrWhiteSpace(Description) && Tags == null; if (allEmpty) { yield return new ValidationResult( "You must provide at least one value to edit: Title, Description, or Tags.", [nameof(Title), nameof(Description), nameof(Tags)] ); } } }