#### 后台代码 ```csharp public class AgeRule : ValidationRule { public int Min { get; set; } public int Max { get; set; }
public override ValidationResult Validate(object value, CultureInfo cultureInfo) { if (!int.TryParse(value as string, out int number)) { return new ValidationResult(false, "输入的内容必须为数字!"); } else if (number > Max || number { return new ValidationResult(false, "输入的年龄超出范围"); } else { return ValidationResult.ValidResult; } } } ```