Thank you for the pointer in the documentation. I have the following entity methods (not validation methods):
**protected override void OnValidateEntityBeforeSave()**
{
base.ValidateFields();
}
** public void ValidateFields()**
{
foreach (Object field in this.Fields)
{
int fieldIndex = this.Fields.IndexOf(field);
if (field.GetType() == typeof(EntityField2))
{
isValid &= this.ValidateFieldValue(fieldIndex,
((EntityField2) field).CurrentValue);
}
}
if (!isValid)
{
this.SetEntityError("Please correct the indicated fields.\n");
}
}
**protected override bool ValidateFieldValue(int fieldIndex, object value)**
{
bool isValidField = true;
string eMsg;
switch ((LeadFieldIndex)fieldIndex)
{
case LeadFieldIndex.EmailAddress:
{
if (((string) value != String.Empty) &&
((string) value != null))
{
Regex normal = new Regex(RegexPatternConst.EMAIL_NORMAL);
isValidField = normal.IsMatch((string) value);
if (isValidField == false)
{
eMsg = "Must be in the form xxxxx@xxxx.xxx";
this.SetEntityFieldError("EmailAddress",
eMsg,
false);
}
else
{
this.SetEntityFieldError("EmailAddress",
String.Empty, false);
}
}
break;
}
default:
isValidField = base.OnValidateFieldValue(fieldIndex, value);
break;
}
return isValidField;
}
At what point is the built-in validation occuring and how do I now it has executed? How do I catch events generated by the built-in validation? How do I know what error it generated?