This commit is contained in:
MeysamMoghaddam
2025-09-28 00:45:26 +03:30
parent 314e2ab425
commit c8924255ac
69 changed files with 398 additions and 1213 deletions

View File

@@ -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);
};
}

View File

@@ -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);
};
}

View File

@@ -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);
};
}

View File

@@ -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);
};
}