108
Chapter 10: Lesson 7: Validating Data to Enforce Business Rules
Exercise 3: About data validation
To ensure that the data entered in the trip edit form is valid, Compass Travel has identified a set of
business rules for capturing and editing trip information. A fundamental concern is ensuring that
the captured data is suitable for the column definitions in the Trips table. This type of validation
on a single field is often referred to as a
single-field edit
.
Compass Travel has
other operating policies that involve evaluating the values from more than
one field. These validations, referred to as
cross-field edits
, are usually more difficult to program.
To ensure that new trips are uniformly captured, Compass Travel has published cross-field
validations and single-field edits in its Compass Travel business rules.
The following table lists the Compass Travel business rules for capturing and editing trip
information. This table identifies which rules require single-field or cross-field editing.
ColdFusion provides numerous ways to validate data. For more information, see Chapter 28,
“Validating Data” in
ColdFusion MX Developer’s Guide
. In this lesson, you use special tags to
simplify the process of enforcing business rules. Using ColdFusion, it is possible to enforce
business rules in several places. For example, you can enforce some validation edits on the client.
You can enforce other validation edits on the server after the data entry form is submitted. You
will explore these options in the following exercises.
Compass Travel new trip policy
Edit type
1
All trips must be named.
Single-field
2
All trips must be accompanied by a full description.
Single-field
3
Each trip must be categorized by event type. Only valid event types (1-surfing, 2-
mountain climbing, and so on) are permissible.
Single-field
4
Trip locations are required.
Single-field
5
The maximum number of people permitted on the trip must be specified.
Single-field
6
The trip departure and return dates must be specified for each trip.
All trip dates must be valid future dates. Departure date must precede return date.
Single-field
Cross-field
7
The trip’s price and base cost are required. Both values are positive numeric
values. The trip price must have at least a 20% markup over base cost.
Cross-field
8
Any trip priced over $750 requires a deposit.
Cross-field
9
A trip leader must be identified.
Single-field
10
A photo must accompany all new trips. The photo image file must reside in the
images directory of the Compass Travel website.
Single-field
Summary of Contents for COLFUSION MX 7-GETTING STARTED BUILDING COLDFUSION...
Page 1: ...COLDFUSION MX7 Getting Started Building ColdFusion MX Applications...
Page 6: ...6 Contents...
Page 10: ......
Page 14: ...14 Chapter 1 Introducing ColdFusion MX...
Page 38: ...38 Chapter 3 Database Fundamentals...
Page 40: ......
Page 58: ...58 Chapter 5 Lesson 2 Configuring Your Development Environment...
Page 70: ...70 Chapter 6 Lesson 3 Retrieving Data...
Page 84: ...84 Chapter 7 Lesson 4 Building Dynamic Queries...
Page 96: ...96 Chapter 8 Lesson 5 Creating a Trip Detail Page...
Page 102: ...102 Chapter 9 Lesson 6 Creating a Main Application Page...