Custom Validator for database checking

Topics: Validation Application Block
Sep 4, 2007 at 4:40 AM
Hello everyone...

l would like to know how to do a custom validator for example... to check if a certain customer already exist in a database...
Normally, l will check the customer email in a database using a method that that will be called by custom validator... if the customer exist it will return true and will not proceed to the insert customer.

Any explaination on how to do it in validation application block or just point me to some examples will be appreciated...

Thanx in advance...
Sep 4, 2007 at 2:26 PM
Hi,

You can use the Application Block factory to help you create the boilerplate code for your validator. You can get the details in the help file. You will probably want to define a Database reference in your configuration object and get a database instance in the constructor for your validator.

However I am not sure a validator like this is appropriate. It is more about validating input for a specific operation than validating the properties of an object. Even when used for integration with a UI, validation rules are still specified to make sense for objects. In this case, unless the validator knows to avoid false positives if the duplicate email belongs to the same customer it is validating the result won't be right.

Regards,
Fernando
Sep 5, 2007 at 7:40 AM
Thank you for the explaination...

Anyway, l think l will use the usual custom validator for checking...

Thanks again...