Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Record Validation Ideas
Message
De
20/03/2003 09:34:46
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
20/03/2003 09:11:43
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00768024
Message ID:
00768042
Vues:
24
>I have a table in a database that I need to add record validation to. The problem is that some of the fields need the validation while others do not.
>
>For instance, My table has 10 fields. 8 of them need to pass a validation clause before they can be updated. The other 2 fields can be updated at any time.
>
>So if a user changes data in one of the 2 fields, there is on validation, it lets him continue without any validation.
>
>But if a user changes data in one of the 8 fields, it applys a rule.
>
>any ideas on how to accomplish this?

Personally, I don't use field and record-level validation, since this causes certain problems.

I do all validation on the form level. The class library has declared a form method, Form.Valid(), which, if it returns .F., doesn't allow saving.

From this method, I call a function which checks my validation rules. All validation rules are saved in a table.

This same function, to check for valid data, could also be called from table triggers, and this would make the validation stricter (for instance, interactive changes in a BROWSE window wouldn't be allowed, either). I didn't do this, but if I would, I would use the triggers, and not record-level validation.

Note that all validation, in this scheme, is postponed until the user actually saves. This makes the program much simpler.

The validation function shows the user a list of rules that have been violated.

My validation function also allows for "warnings": if a rule is marked as a warning, the warning message appears, but the record is saved anyway.
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)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform