using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using LCU.Library.Internal.LoanRateModels.Enums; namespace LCU.Library.Internal.LoanRateModels.Requests.LoadTestRequest; public class LoadTestInitiateRequest { [Required] public RateTypes? RateType { get; set; } [PropertyListValidation] public Dictionary> PropertyList { get; set; } } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)] public class PropertyListValidation : ValidationAttribute { protected override ValidationResult IsValid(object value, ValidationContext validationContext) { if (!(value is Dictionary> dictionary)) return new ValidationResult("Object is not of proper type"); if (dictionary.ContainsKey(nameof(RateRequest.RateType))) { return new ValidationResult($"{nameof(RateRequest.RateType)} cannot be declared in the PropertyList."); } return ValidationResult.Success; } }