BooleanValueValidator.cs 498 B

12345678910111213141516171819202122232425
  1. using System;
  2. namespace Abp.Runtime.Validation
  3. {
  4. [Serializable]
  5. [Validator("BOOLEAN")]
  6. public class BooleanValueValidator : ValueValidatorBase
  7. {
  8. public override bool IsValid(object value)
  9. {
  10. if (value == null)
  11. {
  12. return false;
  13. }
  14. if (value is bool)
  15. {
  16. return true;
  17. }
  18. bool b;
  19. return bool.TryParse(value.ToString(), out b);
  20. }
  21. }
  22. }