Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Field Level Validations and Frameworks
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Field Level Validations and Frameworks
Divers
Thread ID:
00751767
Message ID:
00751767
Vues:
45
Hi

Recently the kind of app I am developing I am required to validate almost every field on the screen with a couple of common functions. To get this kind of validation I had to:

1. Put field.valid() so that once the user is in a field the required value must be entered calling the Business Objects routine for such validations.

cPusCells.Valid()
DODEFAULT()

RETURN THISFORM.ValidAOP(v_tUrineAnalysis.cPusCells, "Pus Cells")
cRBC.Valid()
DODEFAULT()

RETURN THISFORM.ValidAOP(v_tUrineAnalysis.cRBC, "R.B.C.")
... there are a lot of similar calls here


2. To respect the UI and BO seperation rules, I have put in the functions as below in the form and BO:

frmtUrineAnalysis.ValidAOP()
LPARAMETERS tcValue, tcMsg

LOCAL llRetVal

IF THISFORM.botUrineAnalysis.ValidAOP(tcValue, tcMsg)
	llRetVal = .T.
ELSE
	THISFORM.ShowErrorMsg(THISFORM.botUrineAnalysis.GetErrorMsg())

	llRetVal = .F.
ENDIF

RETURN llRetVal
bo_tUrineAnalysis.ValidAOP()
LPARAMETERS tcReading, tcMsg

LOCAL llRetVal

IF INLIST(tcReading, "A", "O", "P")
	llRetVal = .T.
ELSE
	THIS.AddToErrorMsg("Please enter A for Absent, O for Occasional or P for Present for " + tcMsg)

	llRetVal = .F.
ENDIF

RETURN llRetVal
3. Put the same validations in the BeforeSaveValidation() of the Business Object calling respective routines for all the required fields. This will raise the point when new fields are added in a hurry on the form the BO.BeforeSaveValidation() may be missed out. This here cannot be avoided as a few fields are wihtout any valid clause and the user may press Ctrl+S to save the record thus the field.valid() wouldn't fire. Also please note repetition of constants like " Pus Cells" and "R.B.C." in Valid() and here (I can use the Captions defined in this tables).

frmtUrineAnalysis.BeforeSaveValidations()
LOCAL llRetVal

llRetVal = DODEFAULT()

IF "URM"$UPPER(v_LKtPatients.cTest)
	... there are a lot of similar calls here
	IF !THIS.ValidAOP(v_tUrineAnalysis.cPusCells, "Pus Cells")
		llRetVal =  .F.
	ENDIF

	IF !THIS.ValidAOP(v_tUrineAnalysis.crbc, "R.B.C.")
		llRetVal =  .F.
	ENDIF
	... there are a lot of similar calls here
ENDIF

RETURN llRetVal
Now to avoid the above, an idea that I got was to put the valid() call straight in the table using Field Validation Rule. Now the problem is that the actual validation is done in the BO.methods(), if I use a BO call here then I guess browsing through such tables outside the app will become impossible.


Please advise.
Regards
Bhavbhuti
___________________________________________
Softwares for Indian Businesses at:
http://venussoftop.tripod.com
___________________________________________
venussoftop@gmail.com
___________________________________________
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform