Generator Changes at 11/17/2025 11:53:47 PM +03:30
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
using FluentValidation;
|
||||
using CMSMicroservice.Protobuf.Protos.Category;
|
||||
namespace CMSMicroservice.Protobuf.Validator.Category;
|
||||
|
||||
public class CreateNewCategoryRequestValidator : AbstractValidator<CreateNewCategoryRequest>
|
||||
{
|
||||
public CreateNewCategoryRequestValidator()
|
||||
{
|
||||
RuleFor(model => model.Name)
|
||||
.NotEmpty();
|
||||
RuleFor(model => model.Title)
|
||||
.NotEmpty();
|
||||
RuleFor(model => model.IsActive)
|
||||
.NotNull();
|
||||
RuleFor(model => model.SortOrder)
|
||||
.NotNull();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<CreateNewCategoryRequest>.CreateWithOptions((CreateNewCategoryRequest)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using FluentValidation;
|
||||
using CMSMicroservice.Protobuf.Protos.Category;
|
||||
namespace CMSMicroservice.Protobuf.Validator.Category;
|
||||
|
||||
public class DeleteCategoryRequestValidator : AbstractValidator<DeleteCategoryRequest>
|
||||
{
|
||||
public DeleteCategoryRequestValidator()
|
||||
{
|
||||
RuleFor(model => model.Id)
|
||||
.NotNull();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<DeleteCategoryRequest>.CreateWithOptions((DeleteCategoryRequest)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
using FluentValidation;
|
||||
using CMSMicroservice.Protobuf.Protos.Category;
|
||||
namespace CMSMicroservice.Protobuf.Validator.Category;
|
||||
|
||||
public class GetAllCategoryByFilterRequestValidator : AbstractValidator<GetAllCategoryByFilterRequest>
|
||||
{
|
||||
public GetAllCategoryByFilterRequestValidator()
|
||||
{
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<GetAllCategoryByFilterRequest>.CreateWithOptions((GetAllCategoryByFilterRequest)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using FluentValidation;
|
||||
using CMSMicroservice.Protobuf.Protos.Category;
|
||||
namespace CMSMicroservice.Protobuf.Validator.Category;
|
||||
|
||||
public class GetCategoryRequestValidator : AbstractValidator<GetCategoryRequest>
|
||||
{
|
||||
public GetCategoryRequestValidator()
|
||||
{
|
||||
RuleFor(model => model.Id)
|
||||
.NotNull();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<GetCategoryRequest>.CreateWithOptions((GetCategoryRequest)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using FluentValidation;
|
||||
using CMSMicroservice.Protobuf.Protos.Category;
|
||||
namespace CMSMicroservice.Protobuf.Validator.Category;
|
||||
|
||||
public class UpdateCategoryRequestValidator : AbstractValidator<UpdateCategoryRequest>
|
||||
{
|
||||
public UpdateCategoryRequestValidator()
|
||||
{
|
||||
RuleFor(model => model.Id)
|
||||
.NotNull();
|
||||
RuleFor(model => model.Name)
|
||||
.NotEmpty();
|
||||
RuleFor(model => model.Title)
|
||||
.NotEmpty();
|
||||
RuleFor(model => model.IsActive)
|
||||
.NotNull();
|
||||
RuleFor(model => model.SortOrder)
|
||||
.NotNull();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<UpdateCategoryRequest>.CreateWithOptions((UpdateCategoryRequest)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
using FluentValidation;
|
||||
using CMSMicroservice.Protobuf.Protos.PruductCategory;
|
||||
namespace CMSMicroservice.Protobuf.Validator.PruductCategory;
|
||||
|
||||
public class CreateNewPruductCategoryRequestValidator : AbstractValidator<CreateNewPruductCategoryRequest>
|
||||
{
|
||||
public CreateNewPruductCategoryRequestValidator()
|
||||
{
|
||||
RuleFor(model => model.ProductId)
|
||||
.NotEmpty();
|
||||
RuleFor(model => model.CategoryId)
|
||||
.NotEmpty();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<CreateNewPruductCategoryRequest>.CreateWithOptions((CreateNewPruductCategoryRequest)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
using FluentValidation;
|
||||
using CMSMicroservice.Protobuf.Protos.PruductCategory;
|
||||
namespace CMSMicroservice.Protobuf.Validator.PruductCategory;
|
||||
|
||||
public class DeletePruductCategoryRequestValidator : AbstractValidator<DeletePruductCategoryRequest>
|
||||
{
|
||||
public DeletePruductCategoryRequestValidator()
|
||||
{
|
||||
RuleFor(model => model.Id)
|
||||
.NotNull();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<DeletePruductCategoryRequest>.CreateWithOptions((DeletePruductCategoryRequest)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
using FluentValidation;
|
||||
using CMSMicroservice.Protobuf.Protos.PruductCategory;
|
||||
namespace CMSMicroservice.Protobuf.Validator.PruductCategory;
|
||||
|
||||
public class GetAllPruductCategoryByFilterRequestValidator : AbstractValidator<GetAllPruductCategoryByFilterRequest>
|
||||
{
|
||||
public GetAllPruductCategoryByFilterRequestValidator()
|
||||
{
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<GetAllPruductCategoryByFilterRequest>.CreateWithOptions((GetAllPruductCategoryByFilterRequest)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
using FluentValidation;
|
||||
using CMSMicroservice.Protobuf.Protos.PruductCategory;
|
||||
namespace CMSMicroservice.Protobuf.Validator.PruductCategory;
|
||||
|
||||
public class GetPruductCategoryRequestValidator : AbstractValidator<GetPruductCategoryRequest>
|
||||
{
|
||||
public GetPruductCategoryRequestValidator()
|
||||
{
|
||||
RuleFor(model => model.Id)
|
||||
.NotNull();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<GetPruductCategoryRequest>.CreateWithOptions((GetPruductCategoryRequest)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
using FluentValidation;
|
||||
using CMSMicroservice.Protobuf.Protos.PruductCategory;
|
||||
namespace CMSMicroservice.Protobuf.Validator.PruductCategory;
|
||||
|
||||
public class UpdatePruductCategoryRequestValidator : AbstractValidator<UpdatePruductCategoryRequest>
|
||||
{
|
||||
public UpdatePruductCategoryRequestValidator()
|
||||
{
|
||||
RuleFor(model => model.Id)
|
||||
.NotNull();
|
||||
RuleFor(model => model.ProductId)
|
||||
.NotEmpty();
|
||||
RuleFor(model => model.CategoryId)
|
||||
.NotEmpty();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<UpdatePruductCategoryRequest>.CreateWithOptions((UpdatePruductCategoryRequest)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