diff --git a/SimpliClient.cs b/SimpliClient.cs index 2510a51..3170575 100644 --- a/SimpliClient.cs +++ b/SimpliClient.cs @@ -390,7 +390,8 @@ private ProblemDetails GenerateServerErrorProblemDetails(RestRequest request) { "address1", simpliProject.Address1 }, { "suburb", simpliProject.Suburb }, { "state", simpliProject.State.GetDescription() }, - { "country", simpliProject.Country.GetDescription() } + { "country", simpliProject.Country.GetDescription() }, + {"postcode", simpliProject.PostCode} }; if (!string.IsNullOrWhiteSpace(simpliProject.Address2)) { @@ -400,10 +401,6 @@ private ProblemDetails GenerateServerErrorProblemDetails(RestRequest request) { jsonBody.Add("code", simpliProject.Code); } - if (!string.IsNullOrWhiteSpace(simpliProject.PostCode)) - { - jsonBody.Add("postcode", simpliProject.PostCode); - } request.AddJsonBody(jsonBody); diff --git a/Validation/SimpliProjectValidator.cs b/Validation/SimpliProjectValidator.cs new file mode 100644 index 0000000..aa82ac7 --- /dev/null +++ b/Validation/SimpliProjectValidator.cs @@ -0,0 +1,18 @@ +using FluentValidation; +using simpliBuild.SWMS.Model; + +namespace simpliBuild.Validation; + +public class SimpliProjectValidator : AbstractValidator + { + public SimpliProjectValidator() + { + // Validation rules here + RuleFor(project => project.Name).NotEmpty().WithMessage("Project name is required."); + RuleFor(project => project.Address1).NotEmpty().WithMessage("Project address is required."); + RuleFor(project => project.Suburb).NotEmpty().WithMessage("Project suburb is required."); + RuleFor(project => project.PostCode).NotEmpty().WithMessage("Project postcode is required."); +RuleFor(project => project.State).NotEmpty().WithMessage("Project state is required."); +RuleFor(project => project.Country).NotEmpty().WithMessage("Project country is required."); + } +}