问题
I want to build a CompareValidatorAdapter
for Nancy. Can any one give me some pointers as to where I can get the value to be compared?
public override IEnumerable<ModelValidationRule> GetRules(ValidationAttribute attribute, PropertyDescriptor descriptor)
{
var ca = (CompareAttribute)attribute;
yield return new ComparisonValidationRule(attribute.FormatErrorMessage,
new[] { descriptor.Name },
ComparisonOperator.Equal, <WHERE DO I GET THIS VALUE?>);
}
Should I use some sort of reflection technique? I have the feeling I am missing something obvious.
来源:https://stackoverflow.com/questions/24576299/where-do-i-find-object-to-compare-in-comparevalidatoradapter-for-nancy