using System.ComponentModel.DataAnnotations; namespace MVC_SimpleCRUD_Layered.Application.People; public class PersonForm : IValidatableObject { public int? Id { get; set; } [StringLength(100)] [Display(Name = "First name (native)")] public string? FirstName { get; set; } [StringLength(100)] [Display(Name = "Last name (native)")] public string? LastName { get; set; } [Required, StringLength(100)] [Display(Name = "First name (English)")] public string FirstNameTranscription { get; set; } = string.Empty; [Required, StringLength(100)] [Display(Name = "Last name (English)")] public string LastNameTranscription { get; set; } = string.Empty; [StringLength(200)] [Display(Name = "Address")] public string? AddressLine { get; set; } [StringLength(20)] [Display(Name = "Postal Code")] public string? PostalCode { get; set; } [StringLength(100)] public string? City { get; set; } [StringLength(100)] [Display(Name = "Address Country")] public string? AddressCountry { get; set; } [StringLength(255), EmailAddress] public string? Email { get; set; } [StringLength(50), Phone] [Display(Name = "Contact Phone")] public string? ContactPhone { get; set; } [Required] [Display(Name = "Birth Date")] public DateOnly? BirthDate { get; set; } [Required, StringLength(50)] [Display(Name = "Document Number")] public string DocumentNumber { get; set; } = string.Empty; [Required, StringLength(3)] [Display(Name = "Country")] public string CountryCode { get; set; } = string.Empty; public int Page { get; set; } = 1; public int PageSize { get; set; } public string? Sorts { get; set; } public string? SearchText { get; set; } public IEnumerable Validate(ValidationContext validationContext) { if (string.IsNullOrWhiteSpace(Email) && string.IsNullOrWhiteSpace(ContactPhone)) { yield return new ValidationResult( "Email or contact phone is required.", new[] { nameof(Email), nameof(ContactPhone) }); } } }