Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Field Level Error Message
Message
From
31/05/2004 12:07:55
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
31/05/2004 11:36:24
Mike Sue-Ping
Cambridge, Ontario, Canada
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00906987
Message ID:
00908676
Views:
13
>Hilmar,
>
>The response outlining your design to handle validation looks very interesting. I was wondering if you would be willing to share more of it by putting together a small demo. You know what they say, "A picture is worth a thousand words".

Well, I might put it into the download section, eventually, with a small demo form and table.

For now, let me briefly outline the main ideas.

I use it as part of the VFX framework, but it could be integrated into almost any framework.

I will assume that you use buffering.

I postpone almost all validation of data input until the user saves data. This is for several reasons; 1) the user might choose not to input data in the exact order which the programmer prescribes through the TabOrder; 2) some validation rules depend on more than one field; 3) the user might choose to undo the changes, in which case it is a hassle to click an "undo" button, if the "undo" button is on the same form.

To validate a table, say, "Client", create two new records in the validation table, and put the following kind of contents.
Record 1:

Table = Client
Rule = not empty(ClientCode)
Spanish = You must provide a code.
* Note: I had foreseen upgrading to a multilingual system.
* The corresponding language might be chosen, depending on user preferences.
Level = (leave blank) (this makes it a strict rule)

Record 2:

Table = Client
Rule = not empty(ClientNames)
Spanish = The client name can't be empty.
Level = (leave blank)
Then, in the code that saves the record, simply validate for:
RecordValid("Client")
For example, in Visual Extend, this would be:
* Method Form.Valid()
* is invoked by Form.OnSave()
* If valid() returns .F., record isn't saved.
return RecordValid("Client")
If you maintain your record-saving code yourself, the code on your form might look like this:
Form.OnSave()
if RecordValid("Client")
  DoDefault() && Call inherited code, which saves the record
endif
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Reply
Map
View

Click here to load this message in the networking platform