using System.Text.RegularExpressions; using ElectricalRepairServiceContract.Exceptions; using ElectricalRepairServiceContract.Extensions; using ElectricalRepairServiceContract.Interfaces; namespace ElectricalRepairServiceContract.DataModels { public class ClientDataModel : IValidation { public string Id { get; private set; } public string Name { get; private set; } public string Email { get; private set; } public ClientDataModel(string id, string name, string email) { Id = id; Name = name; Email = email; } public void Validate() { if (Id.IsEmpty()) throw new ValidationException("Field DetailsId is empty"); if (!Id.IsGuid()) throw new ValidationException("The value in the field DetailsId is not a unique identifier"); if (Name.IsEmpty()) throw new ValidationException("Field Description is empty"); if (Email.IsEmpty()) throw new ValidationException("Field Cost is empty"); if (!Regex.IsMatch(Email, @"^[^@\s]+@[^@\s]+\.[^@\s]+$")) throw new ValidationException("Field Cost is not a valid email address"); } } }