-
-
Save LSTANCZYK/517ad2e0230df47142288fec3dee087d to your computer and use it in GitHub Desktop.
Custom validation attribute to ensure a checkbox is checked
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// This is used on mostly checkboxes that ensure that they are ticked such as terms and conditions. | |
/// </summary> | |
public class MustBeTrueAttribute : ValidationAttribute | |
{ | |
public override bool IsValid(object value) | |
{ | |
if (value == null) return false; | |
if (value.GetType() != typeof(bool)) return false; | |
return (bool)value; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment