I am trying to validate below property using annotation, either it should be true or false
public bool Info { get; set; }
I will get a invalid data validation error if i pass json like below
{
"info": trues
}
But strange if i pass like below, no data validation.
{ "info": 12345 }
I had tried with ValidationAttribute like below, but value is always true even if val is 12345
public class IsBoolAttribute : ValidationAttribute
{
//public override bool RequiresValidationContext => true;
public override bool IsValid(object value)
{
if (value == null) return false;
if (value.GetType() != typeof(bool)) return false;
return (bool)value;
}
}
