Initial commit - ERP
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
using FluentValidation;
|
||||
using Commerce.Contracts.DTOs;
|
||||
|
||||
namespace Commerce.Contracts.Validators;
|
||||
|
||||
public class CategoryVMValidator : AbstractValidator<CategoryVM>
|
||||
{
|
||||
public CategoryVMValidator()
|
||||
{
|
||||
RuleFor(x => x.Translations).NotEmpty().WithMessage("At least one translation is required");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using FluentValidation;
|
||||
using Commerce.Contracts.DTOs;
|
||||
|
||||
namespace Commerce.Contracts.Validators;
|
||||
|
||||
public class ProductVMValidator : AbstractValidator<ProductVM>
|
||||
{
|
||||
public ProductVMValidator()
|
||||
{
|
||||
RuleFor(x => x.Translations).NotEmpty().WithMessage("At least one translation is required");
|
||||
RuleFor(x => x.Price).GreaterThan(0).When(x => x.Price.HasValue).WithMessage("Price must be greater than 0");
|
||||
RuleFor(x => x.CategoryId).NotEmpty().When(x => !x.IsBundle).WithMessage("Category is required for products");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user