Home  /  Questions  /  Question



250   96.9
Oct 19, 2015


Business Process - Add Validation Unique

Hello,

At the
sample pattern in action. I conclude that the Business Layer has no relationship with Data Layer, but Data Layer who have a relation to Business Layer.
Then I want to ask, what if I want to add validation to a unique value in the Business Layer ?
ex :
AddRule(New ValidateUnique("Code"))

Best Regards,
Eric Santoso



508   99.9
Nov 04, 2015
Hello Eric: 

A unique value can only be detected by querying the database. This means that you will have to do some hand coding. 

In the UI you can use an Ajax call.  In the application server (i.e."code behind') you can execute a database query. Finally in the database itself you probably have a unique constraint (unique index) on the particular value you are checking.

This duplication is the nature of validation if you want the user to have a great user-experience.
Hope this helps.

Jack
 1 comment
 
thank you, I finally put the validation in the presenter, before I do the save method. best regards, Eric Santoso --- Eric Santoso  Nov 12, 2015