DeviationDataModelValidator.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using FluentValidation;
  2. using GreenTree.Nachtragsmanagement.Web.Models.Deviation;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Web;
  7. namespace GreenTree.Nachtragsmanagement.Web.Validation.Admin.User
  8. {
  9. public class DeviationDataModelValidator : AbstractValidator<DeviationDataModel>
  10. {
  11. public DeviationDataModelValidator()
  12. {
  13. RuleFor(m => m.CustomNumber)
  14. .NotEmpty()
  15. .WithMessage("Nummer wird benötigt")
  16. .MaximumLength(10)
  17. .WithMessage("Muss unter 10 Zeichen sein");
  18. RuleFor(m => m.Description)
  19. .NotEmpty()
  20. .WithMessage("Beschreibung wird benötigt");
  21. //RuleFor(m => m.ReceiptDate)
  22. // .NotEmpty()
  23. // .WithMessage("Einreichdatum wird benötigt");
  24. RuleFor(m => m.Value)
  25. .NotEmpty()
  26. .WithMessage("Eine Schätzung wird benötigt");
  27. RuleFor(m => m.Percentage)
  28. .NotEmpty()
  29. .WithMessage("Eine Bewertung wird benötigt");
  30. RuleFor(m => m.StatusId)
  31. .NotEmpty()
  32. .WithMessage("Ein Status muss gewählt werden");
  33. RuleFor(m => m.DisturbanceValues)
  34. .Must(r => r.Count > 0)
  35. .WithMessage("Eine Kategorie muss ausgewählt werden");
  36. RuleFor(m => m.KindId)
  37. .NotEmpty()
  38. .WithMessage("Eine Art muss gewählt werden");
  39. RuleFor(m => m.Comment)
  40. .NotEmpty()
  41. .WithMessage("Ein Kommentar wird benötigt");
  42. }
  43. }
  44. }