Generator Changes at 9/27/2025 10:36:00 AM
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
using FluentValidation;
|
||||
using FrontOffice.BFF.Package.Protobuf.Protos.Package;
|
||||
namespace FrontOffice.BFF.Package.Protobuf.Validator;
|
||||
|
||||
public class CreateNewPackageRequestValidator : AbstractValidator<CreateNewPackageRequest>
|
||||
{
|
||||
public CreateNewPackageRequestValidator()
|
||||
{
|
||||
RuleFor(model => model.Title)
|
||||
.NotEmpty();
|
||||
RuleFor(model => model.Description)
|
||||
.NotEmpty();
|
||||
RuleFor(model => model.ImagePath)
|
||||
.NotEmpty();
|
||||
RuleFor(model => model.Price)
|
||||
.NotNull();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<CreateNewPackageRequest>.CreateWithOptions((CreateNewPackageRequest)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user