All of the data in those controls then passes through a business object
validation method.
Another benefit of this approach that you can't get with control-by-control
"field validation" (at least not without a lot of baroque messing around),
is that it enables you to handle sets of interrelated values that can't be
completely validated until all of the values have been entered. If you
don't do it this way you will find yourself repeating the same tests in
multiple "field validation" methods. Here's a very simple example (if you
have more than two interrelated values it gets much uglier much faster):
Date1.Valid()
If NOT EMPTY(Date2.Value)
* Is Date2 > Date1; if not, wrongo!
ENDIF
Date2.Valid()
* Assumes we can't get here if Date1 is empty...
If THIS.Value <= Date1.Value
* We already asked this, essentially, in Date1 but we have to do it
again here...
ENDIF
Whereas, if we do it all at the same time all we have to do is:
LOCAL DateOne, DateTwo, MyMessage
DateOne = Date1.Value()
DateTwo = Date2.Value()
IF DateOne <= DateTwo
MyMessage = "Date 2 must always be later than Date 1."
ENDIF
IF EMPTY(MyMessage)
** Other validations here
**
**
ENDIF
etc...
IF NOT EMPTY(MyMessage)
* Display the message.
RETURN .F.
ELSE
RETURN .T.
ENDIF
There ya go. It's all in one place; no more digging through multiple
controls to find and change validation rules. No more trying to figure out
who's got focus now and who should get it next (including what you will
have to do if you later decide to change the order in which data is
entered). And if you want to add a second interface to enter some or all of
the same data in a different scenario, perhaps even using different kinds
of controls, you can use this same method to validate it all.
Ken Dibble
www.stic-cil.org
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message:
http://leafe.com/archives/byMID/profox/5.2.1.1.1.20130425220725.01fdb...@pop-server.stny.rr.com
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.