I seem to have an nested boolean which seem to cause trouble for me...
The purpose of the boolean is suppose to check whether an attribute specification it is set for type a or type b?
examaple:
public Enum DateType
{
Integer,
Boolean
}
public class Specification
{
public int? maxInt {get; set;}
public int? minInt {get; set;}
public string? trueText {get; set;}
public string? falseText {get; set;}
}
public class Attribute
{
public DataType Type {get; set;}
public Specification TypeSpecification {get; set;}
}
I then have nested validation for this a validation for this
public static bool IsSpecificationValid(this Attribute newAttribute, DataType type)
{
switch(type)
{
case DateType.Boolean:
var isSpecifationValid =
newAttribute.isBoolean() is true &&
newAttribute.isInteger() is false &&
return isSpecifationValid;
case DateType.Integer:
var isSpecifationValid =
newAttribute.isBoolean() is false &&
newAttribute.isInteger() is true &&
return isSpecifationValid;
}
}
public static bool IsNumber(this Specification newAttribute)
{
return newAttribute.maxInteger != null && newAttribute.minInt != null && newAttribute.maxInt> newAttribute.minInt;
}
public static bool IsBoolean(this Specification newAttribute)
{
return newAttribute.falseText != null && newAttribute.TrueOptionText != null;
}
So problem is when I have this
Attribute a = new Attribute
{
Type = DataType.Integer,
TypeSpecification = new Specification
{
maxInt = 10,
minInt = 2,
trueText = "Incodrre"
}
}
And execute a.IsSpecificationValid(a.Type)
it return as true... which I do get, but cant semantically understand how i make it
return false? what am I doing wrong? since trueText
is part of a boolean but isBoolean should have been givien false?
Removing the condition that I want it give false is also incorrect, sine nothing is avoiding me to set the values, so Incase that both trueText and falseText has been set the IsBoolean condition will return true and then trigger a false statement.
I want to ensure that when Attribute is created that the specification for that type is only filled.