Microsoft provides a Validate component as shown below, in the BizTalk Pipeline interface.
Here's what I tried, and didn't seem to work at all:
public System.Collections.IEnumerator Validate(object projectSystem)
{
System.Collections.ArrayList errorStringArrayList = new System.Collections.ArrayList();
if (this.Substring1ColumnStart >= this.Substring1ColumnEnd)
{
errorStringArrayList.Add("Substring1ColumnEnd must be > SubstringColumn1Start");
}
return (System.Collections.IEnumerator) errorStringArrayList;
}
says
"These error messages appear as compiler error messages. To report successful property validation, the method should return an empty enumerator. "
.
But I'm not getting any compiler messages when I put in invalid values. Also, wouldn't it also do the validation when in BTS-Admin, which would not have "compiler messages"???
Further, why does the Validate receive a generic object as a parm instead of a strongly typed parm? And when is validate called? Each time an propertyBag value is changed?
Update 5/11/2017 at 11:55 AM CT
I tried several more things, two hard to list them all here. I finally got an error, but not a very useful one in the VS compile errors, see screen shot below. It's definitely not the error I returned. Maybe this has an issue on VS2015.
I also got into an issue where I fixed my data, and was still getting the error. Since the Pipeline Componenet is GAC'ed, I was closing and re-opening Visual Studio each time to make sure it got the new copy.
I was thinking maybe that returning anything other than null was the issue. In summary, I have found this practically useless if it doesn't work in BTS-ADMIN. So I will just do run-time errors. Perhaps that's why there is such little documentation and few articles/blogs on this subject.
public System.Collections.IEnumerator Validate(object projectSystem)
{
System.Collections.ArrayList errorStringArrayList = new System.Collections.ArrayList();
if (this.Substring1ColumnStart >= this.Substring1ColumnEnd)
{
errorStringArrayList.Add("Substring1ColumnEnd must be > SubstringColumn1Start");
}
if (errorStringArrayList.Count > 0)
{
return (System.Collections.IEnumerator)errorStringArrayList;
}
else
{
return null;
}
}
This validate method is only called in pipeline design mode. It will not be called in BTS Admin. And if you set some invalid value in your "code". this method is also not called.