private async Task ValidarInput(IObterFreteInput input, CancellationToken cancellationToken) { var validacao = await validador.ValidateAsync(input, cancellationToken); if (!validacao.IsValid) { throw new ArgumentException( JsonConvert.SerializeObject( validacao.Errors.Select(f => f.ErrorMessage))); } }
public async Task <IFrete> Executar(IObterFreteInput input, CancellationToken cancellationToken = default) { await ValidarInput(input, cancellationToken); return(await this.freteServico.ObterFretePeloCep(input.Cep, cancellationToken)); }