public Phone(string ddd, string number) { DomainValidate.Init() .When(string.IsNullOrEmpty(number), "O numero do telefone não pode ser em branco") .When(!string.IsNullOrEmpty(number) && string.IsNullOrEmpty(ddd), "O ddd não pode ser em branco") .ThrowExceptionIfExist(); Ddd = ddd; Number = number; }
public User(Guid id, string name, string email, string password, List <Phone> phones = null) { if (id == Guid.Empty) { Id = Guid.NewGuid(); } DomainValidate.Init() .When(string.IsNullOrEmpty(name), "O nome não pode ser em branco") .When(string.IsNullOrEmpty(email), "O email não pode ser em branco") .When(string.IsNullOrEmpty(password), "A senha não pode ser em branco") .When(string.IsNullOrEmpty(email) || !_emailRegex.Match(email).Success, "O email deve ser preenchido corretamente") .ThrowExceptionIfExist(); Name = name; Email = email; Password = password; Phones = phones; Created = DateTime.Now; Last_login = Created; }