public class ValitTestModel
{
public bool testAttributeA;
public ushort testAttributeB;
public bool validate()
{
var validator = ValitRules<ValitTestModel>
.Create()
.Ensure(m => m.testAttributeA, _ => _
.Required())
.Ensure(m => m.testAttributeB, _ => _
.Required())
.For(this)
.Validate();
return validator.Succeeded;
}
}
The error returned is that The type <bool|ushort> must be a reference type to use it as parameter TProperty for ValitRulePropertyExtensions.Required<TObject, TProperty> where both are defined as classes. C# assumes these to be structs, so it doesn't work.
I did notice however that bool and a few other types have type specific extension methods defined, how do we go about using them?
Very simple test class:
The error returned is that
The type <bool|ushort> must be a reference type to use it as parameter TProperty
forValitRulePropertyExtensions.Required<TObject, TProperty> where both are defined as classes
. C# assumes these to be structs, so it doesn't work.I did notice however that bool and a few other types have type specific extension methods defined, how do we go about using them?