using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Net; using System.Threading.Tasks; namespace Akari.Prototype.Server.Utils { public class IPAddressAttribute : ValidationAttribute { public IPAddressAttribute() : base("Must be a valid IP address") { } public override bool IsValid(object value) { if (value is null) { return true; } return value is string ip && IPAddress.TryParse(ip, out _); } } }