using System.Text.RegularExpressions; namespace OMS.NET.Common { public static class Validations { /// /// 验证颜色值是否有效 /// /// /// public static bool IsHexColor(string color) { // Regex for hex color code (with or without #) var hexColorRegex = new Regex(@"^#?[0-9A-Fa-f]{6}$"); return hexColorRegex.IsMatch(color); } } }