using FluentValidation; using GreenTree.Strohrmann.ERP.Services.Geolocator; using GreenTree.Strohrmann.ERP.Web.Models.Business; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; namespace GreenTree.Strohrmann.ERP.Web.Validators { public class MaterialValidator : AbstractValidator { #region Ctor /// /// Initializes a new instance of the MaterialValidator class /// public MaterialValidator() { RuleFor(m => m.Name) .NotEmpty(); RuleFor(m => m.Description) .NotEmpty(); RuleFor(m => m.ItemNumber) .NotEmpty(); RuleFor(m => m.NetValue) .GreaterThanOrEqualTo(0); RuleFor(m => m.DefaultUnit) .NotNull() .DependentRules(() => { RuleFor(x => x.Height) .GreaterThan(0); RuleFor(x => x.Width) .GreaterThan(0); RuleFor(x => x.Depth) .GreaterThan(0); }); RuleFor(m => m.Supplier) .NotNull(); } #endregion } }