namespace CMSMicroservice.Application.UserCQ.Commands.AcceptContract;
public class AcceptContractCommandValidator : AbstractValidator<AcceptContractCommand>
{
    public AcceptContractCommandValidator()
    {
        RuleFor(model => model.Code)
            .NotEmpty();
        RuleFor(model => model.ContractHtml)
            .NotEmpty();
        RuleFor(model => model.SignGuid)
            .NotEmpty();
    }
    public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
    {
        var result = await ValidateAsync(ValidationContext<AcceptContractCommand>.CreateWithOptions((AcceptContractCommand)model, x => x.IncludeProperties(propertyName)));
        if (result.IsValid)
            return Array.Empty<string>();
        return result.Errors.Select(e => e.ErrorMessage);
    };
}
