I recently discovered the Enterprise Validation Library and am using it to validate my app.config file. I mostly have strings which were simple to apply validation to. I also have some booleans for example:
class Options
{
public bool IsRed { get; set; }
public bool IsBlue { get; set; }
}
and then inside my app.config:
<!--Options-->
<add key ="IsRed" value="true"/>
<add key ="IsBlue" value="Maybe"/>
Is it possible to apply validation rules to check that make sure the value in the app.config file is actually a bool?
The best I've been able to come up with is this:
class Options
{
[TypeConversionValidator(typeof(bool), MessageTemplate = "IsRed value must be a true/false")]
public string IsRed { get; set; }
[TypeConversionValidator(typeof(bool), MessageTemplate = "IsBlue value must be a true/false")]
public string IsBlue { get; set; }
}
Which would work, but then I'm dealing with strings instead of booleans.