30 lines
1.0 KiB
C#
30 lines
1.0 KiB
C#
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<string, List<string>> 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<string, List<string>> 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;
|
|
}
|
|
} |