u
This commit is contained in:
@@ -1,25 +0,0 @@
|
||||
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);
|
||||
};
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
using FluentValidation;
|
||||
using FrontOffice.BFF.Package.Protobuf.Protos.Package;
|
||||
namespace FrontOffice.BFF.Package.Protobuf.Validator;
|
||||
|
||||
public class DeletePackageRequestValidator : AbstractValidator<DeletePackageRequest>
|
||||
{
|
||||
public DeletePackageRequestValidator()
|
||||
{
|
||||
RuleFor(model => model.Id)
|
||||
.NotNull();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<DeletePackageRequest>.CreateWithOptions((DeletePackageRequest)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
using FluentValidation;
|
||||
using FrontOffice.BFF.Package.Protobuf.Protos.Package;
|
||||
namespace FrontOffice.BFF.Package.Protobuf.Validator;
|
||||
|
||||
public class UpdatePackageRequestValidator : AbstractValidator<UpdatePackageRequest>
|
||||
{
|
||||
public UpdatePackageRequestValidator()
|
||||
{
|
||||
RuleFor(model => model.Id)
|
||||
.NotNull();
|
||||
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<UpdatePackageRequest>.CreateWithOptions((UpdatePackageRequest)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
using FluentValidation;
|
||||
using FrontOffice.BFF.User.Protobuf.Protos.User;
|
||||
namespace FrontOffice.BFF.User.Protobuf.Validator;
|
||||
|
||||
public class CreateNewUserRequestValidator : AbstractValidator<CreateNewUserRequest>
|
||||
{
|
||||
public CreateNewUserRequestValidator()
|
||||
{
|
||||
RuleFor(model => model.Mobile)
|
||||
.NotEmpty();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<CreateNewUserRequest>.CreateWithOptions((CreateNewUserRequest)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