-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EES-5047: Move string length and message definitions into constants, …
…update naming convention for "DataSet" in validation messaging.
- Loading branch information
Tom Jones
committed
Dec 13, 2024
1 parent
6be80fa
commit 3345df9
Showing
14 changed files
with
218 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 29 additions & 7 deletions
36
src/GovUk.Education.ExploreEducationStatistics.Admin/Requests/DataGuidanceUpdateRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,47 @@ | ||
#nullable enable | ||
using FluentValidation; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel.DataAnnotations; | ||
using static GovUk.Education.ExploreEducationStatistics.Common.Constants.ValidationConstants; | ||
|
||
namespace GovUk.Education.ExploreEducationStatistics.Admin.Requests; | ||
|
||
public record DataGuidanceUpdateRequest | ||
{ | ||
[Required] | ||
public string Content { get; init; } = string.Empty; | ||
|
||
[MinLength(1)] | ||
public List<DataGuidanceDataSetUpdateRequest> DataSets { get; init; } = new(); | ||
public List<DataGuidanceDataSetUpdateRequest> DataSets { get; init; } = []; | ||
|
||
public class Validator : AbstractValidator<DataGuidanceUpdateRequest> | ||
{ | ||
public Validator() | ||
{ | ||
RuleFor(request => request.Content) | ||
.NotEmpty(); | ||
|
||
RuleFor(request => request.DataSets) | ||
.NotEmpty(); | ||
} | ||
} | ||
} | ||
|
||
public record DataGuidanceDataSetUpdateRequest | ||
{ | ||
[Required] | ||
public Guid FileId { get; init; } | ||
|
||
[Required] | ||
[MaxLength(250, ErrorMessage = "File guidance content must be 250 characters or less")] | ||
public string Content { get; init; } = string.Empty; | ||
|
||
public class Validator : AbstractValidator<DataGuidanceDataSetUpdateRequest> | ||
{ | ||
public Validator() | ||
{ | ||
RuleFor(request => request.FileId) | ||
.NotEmpty(); | ||
|
||
RuleFor(request => request.Content) | ||
.NotEmpty() | ||
.MaximumLength(FileGuidanceContentMaxLength) | ||
.WithMessage(FileGuidanceContentMaxLengthMessage); | ||
} | ||
} | ||
} |
42 changes: 33 additions & 9 deletions
42
src/GovUk.Education.ExploreEducationStatistics.Admin/Requests/FeaturedTableRequests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,54 @@ | ||
#nullable enable | ||
using FluentValidation; | ||
using System; | ||
using System.ComponentModel.DataAnnotations; | ||
using static GovUk.Education.ExploreEducationStatistics.Common.Constants.ValidationConstants; | ||
|
||
namespace GovUk.Education.ExploreEducationStatistics.Admin.Requests; | ||
|
||
public record FeaturedTableCreateRequest | ||
{ | ||
[Required] | ||
[MaxLength(120, ErrorMessage = "Featured table name must be 120 characters or less")] | ||
public string Name { get; init; } = string.Empty; | ||
|
||
[Required] | ||
[MaxLength(200, ErrorMessage = "Featured table description must be 200 characters or less")] | ||
public string Description { get; set; } = string.Empty; | ||
|
||
public Guid DataBlockId { get; set; } | ||
|
||
public class Validator : AbstractValidator<FeaturedTableCreateRequest> | ||
{ | ||
public Validator() | ||
{ | ||
RuleFor(request => request.Name) | ||
.NotEmpty() | ||
.MaximumLength(FeaturedTableNameMaxLength) | ||
.WithMessage(FeaturedTableNameMaxLengthMessage); | ||
|
||
RuleFor(request => request.Description) | ||
.NotEmpty() | ||
.MaximumLength(FeaturedTableDescriptionMaxLength) | ||
.WithMessage(FeaturedTableDescriptionMaxLengthMessage); | ||
} | ||
} | ||
} | ||
|
||
public record FeaturedTableUpdateRequest | ||
{ | ||
[Required] | ||
[MaxLength(120, ErrorMessage = "Featured table name must be 120 characters or less")] | ||
public string Name { get; init; } = string.Empty; | ||
|
||
[Required] | ||
[MaxLength(200, ErrorMessage = "Featured table description must be 200 characters or less")] | ||
public string Description { get; set; } = string.Empty; | ||
|
||
public class Validator : AbstractValidator<FeaturedTableUpdateRequest> | ||
{ | ||
public Validator() | ||
{ | ||
RuleFor(request => request.Name) | ||
.NotEmpty() | ||
.MaximumLength(FeaturedTableNameMaxLength) | ||
.WithMessage(FeaturedTableNameMaxLengthMessage); | ||
|
||
RuleFor(request => request.Description) | ||
.NotEmpty() | ||
.MaximumLength(FeaturedTableDescriptionMaxLength) | ||
.WithMessage(FeaturedTableDescriptionMaxLengthMessage); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.