Page 1 of 1

validate datatype

Posted: Sat May 02, 2009 4:10 pm
by vennam445
Hi,
I want to validate the data types of the source records.After validating I should pass all invalid data to the reject link and valid data to output link.I am using isvalid() function for this but don't know how to direct the reject records to output link.

Posted: Sat May 02, 2009 5:14 pm
by chulett
The 'direction' would be controlled by constraints. Perhaps leverage stage variables, one for each field to validate. Valid = 0, Invalid = 1 and lastly sum them. Good row constraint: sum = 0, reject everything else. Something like that, anywho. :wink:

Posted: Mon May 04, 2009 2:32 am
by sbass1
chulett wrote:The 'direction' would be controlled by constraints. Perhaps leverage stage variables, one for each field to validate. Valid = 0, Invalid = 1 and lastly sum them. Good row constraint: sum = 0, reject everything else. Something like that, anywho. :wink:
I take this exact approach in code I've written, except I want an audit field to tell me which fields were in error.

Snippets of my code are:

Stage variables C1-C20 ("constraint" 1 - 20)

C1: If IsNull(Lookup_Account.AccountNK) Then "GL4Account;" Else \\
C2: If IsNull(Lookup_Bus_Unit.BusinessUnitNK) Then "GL4BusinessUnit;" Else \\

etc...

Audit: If Len(Trim(C1:C2:C3:C4:C5:C6:C7:C8:C9:C10:C11:C12:C13:C14:C15)," ","A") ne 0 Then " Failed Lookups: " : (C1:C2:C3:C4:C5:C6:C7:C8:C9:C10:C11:C12:C13:C14:C15) Else \\

InvalidRecord: Len(Audit) ne 0

Then my constraints are Not(InvalidRecord) for good records, and InvalidRecord for bad records.

If you use Craig's approach with boolean values for validation checks, replace Len(...) with either C1+C2+C3+... or Sum(C1:@FM:C2:@FM:C3:...) (See doc for SUM function)

HTH...

Scott