diff --git a/src/GovUk.Education.ExploreEducationStatistics.Admin/Controllers/Api/ReleasesController.cs b/src/GovUk.Education.ExploreEducationStatistics.Admin/Controllers/Api/ReleasesController.cs index 7f1003b4f6..87440621bc 100644 --- a/src/GovUk.Education.ExploreEducationStatistics.Admin/Controllers/Api/ReleasesController.cs +++ b/src/GovUk.Education.ExploreEducationStatistics.Admin/Controllers/Api/ReleasesController.cs @@ -14,7 +14,6 @@ using System.ComponentModel.DataAnnotations; using System.Threading; using System.Threading.Tasks; -using static GovUk.Education.ExploreEducationStatistics.Common.Constants.ValidationConstants; namespace GovUk.Education.ExploreEducationStatistics.Admin.Controllers.Api { @@ -109,7 +108,7 @@ public async Task>> ReorderDataFiles(Guid releas public async Task> UploadDataSet(Guid releaseVersionId, [FromQuery(Name = "replacingFileId")] Guid? replacingFileId, [FromQuery(Name = "title")] - [MaxLength(SubjectTitleMaxLength, ErrorMessage = SubjectTitleMaxLengthMessage)] + [MaxLength(120)] string title, IFormFile file, IFormFile metaFile) @@ -129,7 +128,7 @@ public async Task> UploadDataSet(Guid releaseVersionI public async Task> UploadDataSetAsZip(Guid releaseVersionId, [FromQuery(Name = "replacingFileId")] Guid? replacingFileId, [FromQuery(Name = "title")] - [MaxLength(SubjectTitleMaxLength, ErrorMessage = SubjectTitleMaxLengthMessage)] + [MaxLength(120)] string title, IFormFile zipFile) { diff --git a/src/GovUk.Education.ExploreEducationStatistics.Admin/Requests/DataBlockRequests.cs b/src/GovUk.Education.ExploreEducationStatistics.Admin/Requests/DataBlockRequests.cs index 6d2fe6767c..d81e49514c 100644 --- a/src/GovUk.Education.ExploreEducationStatistics.Admin/Requests/DataBlockRequests.cs +++ b/src/GovUk.Education.ExploreEducationStatistics.Admin/Requests/DataBlockRequests.cs @@ -4,7 +4,6 @@ using GovUk.Education.ExploreEducationStatistics.Common.Model.Data; using GovUk.Education.ExploreEducationStatistics.Common.Requests; using System.Collections.Generic; -using static GovUk.Education.ExploreEducationStatistics.Common.Constants.ValidationConstants; namespace GovUk.Education.ExploreEducationStatistics.Admin.Requests; @@ -28,8 +27,7 @@ public Validator() { RuleFor(request => request.Heading) .NotEmpty() - .MaximumLength(TableTitleMaxLength) - .WithMessage(TableTitleMaxLengthMessage); + .MaximumLength(120); RuleFor(request => request.Name) .NotEmpty(); @@ -60,8 +58,7 @@ public Validator() { RuleFor(request => request.Heading) .NotEmpty() - .MaximumLength(TableTitleMaxLength) - .WithMessage(TableTitleMaxLengthMessage); + .MaximumLength(120); RuleFor(request => request.Name) .NotEmpty(); diff --git a/src/GovUk.Education.ExploreEducationStatistics.Admin/Requests/DataGuidanceUpdateRequest.cs b/src/GovUk.Education.ExploreEducationStatistics.Admin/Requests/DataGuidanceUpdateRequest.cs index b057848d57..e854959c8e 100644 --- a/src/GovUk.Education.ExploreEducationStatistics.Admin/Requests/DataGuidanceUpdateRequest.cs +++ b/src/GovUk.Education.ExploreEducationStatistics.Admin/Requests/DataGuidanceUpdateRequest.cs @@ -2,7 +2,6 @@ using FluentValidation; using System; using System.Collections.Generic; -using static GovUk.Education.ExploreEducationStatistics.Common.Constants.ValidationConstants; namespace GovUk.Education.ExploreEducationStatistics.Admin.Requests; @@ -40,8 +39,7 @@ public Validator() RuleFor(request => request.Content) .NotEmpty() - .MaximumLength(FileGuidanceContentMaxLength) - .WithMessage(FileGuidanceContentMaxLengthMessage); + .MaximumLength(250); } } } diff --git a/src/GovUk.Education.ExploreEducationStatistics.Admin/Requests/FeaturedTableRequests.cs b/src/GovUk.Education.ExploreEducationStatistics.Admin/Requests/FeaturedTableRequests.cs index fe6ead1a18..43933bc124 100644 --- a/src/GovUk.Education.ExploreEducationStatistics.Admin/Requests/FeaturedTableRequests.cs +++ b/src/GovUk.Education.ExploreEducationStatistics.Admin/Requests/FeaturedTableRequests.cs @@ -1,7 +1,6 @@ #nullable enable using FluentValidation; using System; -using static GovUk.Education.ExploreEducationStatistics.Common.Constants.ValidationConstants; namespace GovUk.Education.ExploreEducationStatistics.Admin.Requests; @@ -19,13 +18,11 @@ public Validator() { RuleFor(request => request.Name) .NotEmpty() - .MaximumLength(FeaturedTableNameMaxLength) - .WithMessage(FeaturedTableNameMaxLengthMessage); + .MaximumLength(120); RuleFor(request => request.Description) .NotEmpty() - .MaximumLength(FeaturedTableDescriptionMaxLength) - .WithMessage(FeaturedTableDescriptionMaxLengthMessage); + .MaximumLength(200); } } } @@ -42,13 +39,11 @@ public Validator() { RuleFor(request => request.Name) .NotEmpty() - .MaximumLength(FeaturedTableNameMaxLength) - .WithMessage(FeaturedTableNameMaxLengthMessage); + .MaximumLength(120); RuleFor(request => request.Description) .NotEmpty() - .MaximumLength(FeaturedTableDescriptionMaxLength) - .WithMessage(FeaturedTableDescriptionMaxLengthMessage); + .MaximumLength(200); } } } diff --git a/src/GovUk.Education.ExploreEducationStatistics.Admin/Requests/ReleaseFileRequests.cs b/src/GovUk.Education.ExploreEducationStatistics.Admin/Requests/ReleaseFileRequests.cs index f9bf20a2a8..4f8c11a184 100644 --- a/src/GovUk.Education.ExploreEducationStatistics.Admin/Requests/ReleaseFileRequests.cs +++ b/src/GovUk.Education.ExploreEducationStatistics.Admin/Requests/ReleaseFileRequests.cs @@ -1,7 +1,6 @@ #nullable enable using FluentValidation; using Microsoft.AspNetCore.Http; -using static GovUk.Education.ExploreEducationStatistics.Common.Constants.ValidationConstants; namespace GovUk.Education.ExploreEducationStatistics.Admin.Requests; @@ -16,8 +15,7 @@ public class Validator : AbstractValidator public Validator() { RuleFor(request => request.Title) - .MaximumLength(SubjectTitleMaxLength) - .WithMessage(SubjectTitleMaxLengthMessage); + .MaximumLength(120); } } } @@ -36,13 +34,11 @@ public Validator() { RuleFor(request => request.Title) .NotEmpty() - .MaximumLength(TitleMaxLength) - .WithMessage(TitleMaxLengthMessage); + .MaximumLength(120); RuleFor(request => request.Summary) .NotEmpty() - .MaximumLength(SummaryMaxLength) - .WithMessage(SummaryMaxLengthMessage); + .MaximumLength(250); RuleFor(request => request.File) .NotEmpty(); @@ -64,13 +60,11 @@ public Validator() { RuleFor(request => request.Title) .NotEmpty() - .MaximumLength(TitleMaxLength) - .WithMessage(TitleMaxLengthMessage); + .MaximumLength(120); RuleFor(request => request.Summary) .NotEmpty() - .MaximumLength(SummaryMaxLength) - .WithMessage(SummaryMaxLengthMessage); + .MaximumLength(250); } } } diff --git a/src/GovUk.Education.ExploreEducationStatistics.Admin/Services/DataArchiveValidationService.cs b/src/GovUk.Education.ExploreEducationStatistics.Admin/Services/DataArchiveValidationService.cs index 2731cf1b6c..ae3b51bcc3 100644 --- a/src/GovUk.Education.ExploreEducationStatistics.Admin/Services/DataArchiveValidationService.cs +++ b/src/GovUk.Education.ExploreEducationStatistics.Admin/Services/DataArchiveValidationService.cs @@ -15,7 +15,6 @@ using System.IO.Compression; using System.Linq; using System.Threading.Tasks; -using static GovUk.Education.ExploreEducationStatistics.Common.Constants.ValidationConstants; namespace GovUk.Education.ExploreEducationStatistics.Admin.Services { @@ -143,7 +142,7 @@ public async Task>> ValidateBulkDa var filename = row[fileNameIndex]; var datasetName = row[datasetNameIndex].Trim(); - if (datasetName.Length > SubjectTitleMaxLength) + if (datasetName.Length > 120) { errors.Add(ValidationMessages.GenerateErrorDataSetTitleTooLong(datasetName)); } diff --git a/src/GovUk.Education.ExploreEducationStatistics.Common/Constants/ValidationConstants.cs b/src/GovUk.Education.ExploreEducationStatistics.Common/Constants/ValidationConstants.cs deleted file mode 100644 index 69bf57be26..0000000000 --- a/src/GovUk.Education.ExploreEducationStatistics.Common/Constants/ValidationConstants.cs +++ /dev/null @@ -1,25 +0,0 @@ -namespace GovUk.Education.ExploreEducationStatistics.Common.Constants; - -public class ValidationConstants -{ - public const int TitleMaxLength = 120; - public const string TitleMaxLengthMessage = "Title must be 120 characters or less"; - - public const int SummaryMaxLength = 250; - public const string SummaryMaxLengthMessage = "Summary must be 250 characters or less"; - - public const int SubjectTitleMaxLength = 120; - public const string SubjectTitleMaxLengthMessage = "Subject title must be 120 characters or less"; - - public const int TableTitleMaxLength = 120; - public const string TableTitleMaxLengthMessage = "Table title must be 120 characters or less"; - - public const int FeaturedTableNameMaxLength = 120; - public const string FeaturedTableNameMaxLengthMessage = "Featured table name must be 120 characters or less"; - - public const int FeaturedTableDescriptionMaxLength = 200; - public const string FeaturedTableDescriptionMaxLengthMessage = "Featured table description must be 200 characters or less"; - - public const int FileGuidanceContentMaxLength = 250; - public const string FileGuidanceContentMaxLengthMessage = "File guidance content must be 250 characters or less"; -}