I'm having my validation rule handler with following signature
Private Shared Function OrderCfmDtChk(Of T As Order)(ByVal target As T, _
ByVal e As Validation.RuleArgs) As Boolean
here the e parameter is also a subclass of RuleArgs and thus provides additional parameter, I'm trying to add this rule with following line but is giving a compile time error :-
ValidationRules.AddRule(
Of Order)(AddressOf OrderCfmDtChk(Of Order), _ New DaysValueRuleArgs("OrderCfmDt", 7))
Can anybody help in this..
can anybody help on this.
If i don't use the custom RuleArgs then below given line is working fine, and is performing validation also.
ValidationRules.AddRule(
Of Order)(AddressOf OrderCfmDtChk(Of Order), "OrderCfmDt")but in this case i have to hard code value inside the validator, whereas i want to pass additional parameters through custom Rule Args as specified in my initial post.
Kindly note i have done that and this is the method signature for the same
Private Shared Function OrderCfmDtChk(Of T As Order)(ByVal target As T, _
ByVal e As Validation.RuleArgs) As Boolean
But when i use following line to add this rule, it is giving compile timer error :-
ValidationRules.AddRule(Of Order)(AddressOf OrderCfmDtChk(Of Order), _
New DaysValueRuleArgs("OrderCfmDt", 7))
Can you pls help me in telling what code i should exactly write so this rule can be added.
Further to my previous message, this is the custom Rule Args class, Validation rule handler converts the passed e parameter to this class by using following code
Dim
Days As Integer = CType(e, DaysValueRuleArgs).Days
Public Class DaysValueRuleArgs
Inherits Csla.Validation.RuleArgs
Private mDays As Integer
Public ReadOnly Property Days() As Integer Get Return mDays End Get End Property Public Sub New(ByVal propertyName As String, ByVal Days As Integer) MyBase.New(propertyName)mDays = Days
End Sub Public Overrides Function ToString() As String Return MyBase.ToString & "?Days=" & mDays.ToString End Function End Classplease excuse me for nagging so much for this problem but i'm still not able to get rid of compiler errors. can u pls help me in advising what is the exact line to write through which this rule can be added, pls help
Here is the summary of my previous posts.
Custom Rules Args :- DaysValueRuleArgs
Validation routine :- OrderCfmDtChk (Signature was given in my previous post)
I'm writing following line currently and it is giving compile time error :-
ValidationRules.AddRule(Of Order)(AddressOf OrderCfmDtChk(Of Order), _
New DaysValueRuleArgs("OrderCfmDt", 7))
MaxValue and MaxValueRuleArgs for more info
This is the AddRule line :-
ValidationRules.AddRule(
AddressOf OrderCfmDtChk(Of Integer), _ New DaysValueRuleArgs(Of Integer)("OrderCfmDt", 7))Here is the validator signature and few important lines of code to retreive property value & parameter value :-
Private
Shared Function OrderCfmDtChk(Of T As IComparable)(ByVal target As Object, _ ByVal e As Validation.RuleArgs) As Boolean Dim PropValue As String = CStr(CallByName(target, e.PropertyName, CallType.Get)) Dim Days As Integer = DirectCast(e, DaysValueRuleArgs(Of Integer)).Days
& Finally here is the custom rule args and it's new constructor
Public
Class DaysValueRuleArgs(Of T)........
Public Sub New(ByVal propertyName As String, ByVal Days As Integer)
I hope this will help if somebody else is trying this...
Copyright (c) Marimer LLC