GreaterThanZeroAttribute.cs 443 B

12345678910111213141516171819
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel.DataAnnotations;
  4. using System.Text;
  5. namespace CZFW.Framework.Attributes
  6. {
  7. public class GreaterThanZeroAttribute : ValidationAttribute
  8. {
  9. public override bool IsValid(object value)
  10. {
  11. int? x = value as int?;
  12. if (x == null) return false;
  13. if (x <= 0) return false;
  14. return true;
  15. }
  16. }
  17. }