using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FluentValidation;
using Hotline.Share.Dtos.FlowEngine;
using Hotline.Application.Contracts.Validators;
using Hotline.Share.Enums.FlowEngine;

namespace Hotline.Application.Contracts.Validators.FlowEngine
{
    public class StartWorkflowDtoValidator : AbstractValidator<StartWorkflowDto>
    {
        public StartWorkflowDtoValidator()
        {
            //RuleFor(d => d.DefinitionCode)
            //    .NotEmpty().When(d => string.IsNullOrEmpty(d.DefinitionModuleCode));
            //RuleFor(d => d.DefinitionModuleCode)
            //    .NotEmpty().When(d => string.IsNullOrEmpty(d.DefinitionCode));

            //RuleFor(d => d.DefinitionModuleCode).NotEmpty();
            //RuleFor(d => d.Title).NotEmpty();
            RuleFor(d => d.NextStepCode).NotEmpty();
            RuleFor(d => d.IsSms).NotNull();
            RuleFor(d => d.IsStartCountersign).NotNull();
            RuleFor(d => d.NextHandlers.Count).LessThanOrEqualTo(1)
                .Unless(d => d.IsStartCountersign);
            RuleFor(d => d.Opinion)
                .Cascade(CascadeMode.Stop)
                .NotEmpty()
                .MaximumLength(2000);
        }
    }
}
