Samples > Starter stores > Starter store enhancements > IBM Gift Center for the Madisons starter store > Work with the sample store pages > Create a custom business validation rule


IBM Gift Center for Madisons: Adding the new business validation rule to the GRREGRULE table

To implement a new business validation rule, add an entry for the rule to the GRREGRULE table. This table contains all Gift Center business validation rules. Each rule must be represented by an ID in the table.


Before you begin

Review the following topics to learn about the GRRREGRULE table and business validation rules for Gift Center:


Procedure

Write an SQL statement to add the new business validation rule to the GRREGRULE table.

The following SQL statement provides an example you can modify for the rule:

INSERT INTO GRREGRULE 
(GRREGRULE_ID, STOREID, NAME, DESCRIPTION, EVENTTYPENAME, GRRULEVAL) 
VALUES 
(
7000, 
10101, 
7001, 
'The number of registries allowed per registrant for each event type should not exceed a preconfigured maximum number', 
'Default', 
'1'
)

Where:

GRREGRULE_ID

The unique ID that to assign to this rule, for example, 7000. Use an integer. Make sure the number has not already been assigned to another rule in the GRREGRULE table.

STOREID

The store entity ID as defined in the STORE_ID column of the STORE table. If you want this rule to apply to all stores, specify -1 for the STOREID value.

In the previous SQL example, the validation rule applies only to store 10101.

NAME

A unique number representing the name of this rule, for example, 7001.

DESCRIPTION

A description of the rule. The purpose of the description is only to explain the rule in the database.

EVENTTYPENAME

The name of the event type to which this rule applies. Valid event types are:

  • Default – Use this value to apply the rule to all event types, that is, Wedding, Anniversary, Birthday, and Other.

  • Wedding

  • Anniversary

  • Birthday

  • Other

  • WishList – Use this value if the rule is for wish lists. The default validators will check whether the gift list type is a gift registry or a wish list before applying a rule value.

GRRULEVAL

The value against which the rule will be validated.

In the previous SQL example, this value is set to 1. This means that a customer can create only one gift registry per event type. For example, this validation rule prevents customers from creating more than one Wedding gift registry or more than one Anniversary gift registry.


Next topic: IBM Gift Center for Madisons: Creating a new validator class for the business validation rule


+

Search Tips   |   Advanced Search