public bool IsValid(UpdateContatoModel model, ICommand command) { if (string.IsNullOrEmpty(model.canal)) { return(true); } if (!model.canal.Equals("Celular") && !model.canal.Equals("E-mail") && !model.canal.Equals("Telefone")) { command.AddNotification(new Notification { key = "canal", value = string.Format("Apenas Celular, E-mail e Telefone são considerados válidos como canal.", model.canal) }); return(false); } return(true); }
public bool IsValid(string model, ICommand command) { if (string.IsNullOrEmpty(model)) { return(true); } var resultFrom = _repository.Get(model).Result; if (resultFrom == null) { command.AddNotification(new Notification { key = "id", value = "O Contato informado não existe" }); return(false); } return(true); }
public bool IsValid(UpdateContatoModel model, ICommand command) { if (string.IsNullOrEmpty(model.canal) || string.IsNullOrEmpty(model.valor)) { return(true); } if (model.canal.Equals("Telefone") || model.valor.Equals("Celular")) { var regex = @"^(([1-9]{1}[0-9]{1}[9]{1}[0-9]{4}[0-9]{4})|([1-9]{1}[0-9]{1}[1-8]{1}[0-9]{3}[0-9]{4}))$"; Match match = Regex.Match(model.valor, regex, RegexOptions.IgnoreCase); if (!match.Success) { command.AddNotification(new Notification { key = "valor", value = string.Format("O valor não corresponde a um {0}", model.canal) }); return(false); } } return(true); }
public bool IsValid(CreateContatoModel model, ICommand command) { if (string.IsNullOrEmpty(model.canal) || string.IsNullOrEmpty(model.valor)) { return(true); } if (model.canal.Equals("E-mail")) { var regex = @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$"; Match match = Regex.Match(model.valor, regex, RegexOptions.IgnoreCase); if (!match.Success) { command.AddNotification(new Notification { key = "valor", value = "O valor informado não corresponde a um E-mail" }); return(false); } } return(true); }