using PapaCarloContracts.Enums; using PapaCarloContracts.Exceptions; using PapaCarloContracts.Extensions; using PapaCarloContracts.infrastructure; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace PapaCarloContracts.DataModels; public class PostDataModel(string id, string postName, PostType postType,bool isActual, DateTime changeDate) : IValidation { public string Id { get; private set; } = id; public string PostName { get; private set; } = postName; public PostType PostType { get; private set; } = postType; public bool IsActual { get; private set; } = isActual; public DateTime ChangeDate { get; private set; } = changeDate; public void Validate() { if (Id.IsEmpty()) throw new ValidationException("Field Id is empty"); if (!Id.IsGuid()) throw new ValidationException("The value in the field Id is not a unique identifier"); if (PostName.IsEmpty()) throw new ValidationException("Field PostName is empty"); if (PostType == PostType.None) throw new ValidationException("Field PostType is empty"); } }