Can I create a strongly typed rule within a class and "assign" it to a non-existant property of the class like this? There is no Boolean Property named NoneChecked in my class. I simply want to check if one of the other 4 Boolean properties has been checked. I did this a lot in CSLA 1.x - just want to know if there is any problem with it in 2.0.
Protected Overrides Sub AddBusinessRules()
'NoneChecked
ValidationRules.AddRule(Of MyBO, MyRuleArgs)(AddressOf AtLeastOneIsChecked, New MyRuleArgs("NoneChecked"))
End Sub
Private Shared Function AtLeastOneIsChecked(Of T As MyBO, R As MyRuleArgs)(ByVal target As T, ByVal e As R) As Boolean
If Not (target.mChkCode OrElse target.mChkDesc OrElse target.mChkGrp OrElse target.mChkStatus) Then
e.Description = "You must check at least one of the checkboxes."
Return False
Else
Return True
End If
End Function
Joe
Thanks - that's what I wanted to know.
I do call ValidationRules.CheckRules("NoneChecked") at least once.
Joe
Copyright (c) Marimer LLC