daelmo wrote:
I think here is recommended to validate GUI-side too. This way the PerformWork wont be called unless all field values are ok.
How your validator code looks like? Please post (or attach) the validator code.
I am using the classic ASP.NET validators for simple validation like for required field, data type, length. For more complex business rules I have created a custom validator for the my llbl entity. I would like to call ValidateEntity() before the PerformWork triggers like in formView ItemInserting event.
So far my validator looks like this:
[DependencyInjectionInfo(typeof(MyEntity), "Validator", ContextType = DependencyInjectionContextType.Singleton)]
public class MyEntityValidator: ValidatorBase
{
public override void ValidateEntityBeforeSave(IEntityCore involvedEntity)
{
MyEntity toValidate = involvedEntity as MyEntityEntity;
throw new ORMEntityValidationException("Custom Validation Exception Test", toValidate);
}
public override void ValidateEntity(IEntityCore involvedEntity)
{
ValidateEntityBeforeSave(involvedEntity);
}
}