protected override ValidationResult IsValid()

in Webapp/SDAF/Models/CustomValidators.cs [342:358]


            protected override ValidationResult IsValid(object value, ValidationContext context)
            {
                bool isDefault = (bool)context.ObjectInstance.GetType().GetProperty("IsDefault").GetValue(context.ObjectInstance);
                if (isDefault) return ValidationResult.Success;

                string prefix = (string)value;
                string armId = (string)context.ObjectInstance.GetType().GetProperty("network_arm_id").GetValue(context.ObjectInstance);

                if (prefix == null && armId == null)
                {
                    return new ValidationResult($"At least one of network_address_space or network_arm_id must be present.");
                }
                else
                {
                    return ValidationResult.Success;
                }
            }