public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { var validator = new StockDtoValidator(); var result = validator.Validate(this); return(result.Errors.Select(item => new ValidationResult(item.ErrorMessage, new[] { item.PropertyName }))); }
public Validator(StockDtoValidator stockDtoValidator) { RuleFor(x => x.Stocks).NotEmpty(); RuleForEach(x => x.Stocks).SetValidator(stockDtoValidator); }