Supporting File Structures|Rule (Class) Files
Rule or Class files define a set of rules a data value must adhere to in order to be assessed as a legal member of that data class.
For example, a UK post code must adhere to a number of defined rules in order to be deemed a correct and legal post code.
These rules are laid out in two sections within a Rule File, a MANDATORY section and an OPTIONAL section.
The MANDATORY section contains rules that must be adhered to all of the time.
The OPTIONAL section normally contains one or more rules, some of which the data value must adhere to.
A typical Rule File is shown below. (This one is a Rule File for UK Post Codes).
# FindDataBugs Rule File Version 1.00
#
# Any value matching ANY of the clauses below is deemed to be in class
#
# Sample entries
#
# :MANDATORY_SECTION // The current data value must match all mandatory conditions.
# // There can only be one MANDATORY_SECTION.
# mandatory_condition1 clause
# mandatory_condition2 clause
# ...
#
#
# :OPTIONAL_SECTION :n // Any n from the total number of optional conditions in the current :OPTIONAL_SECTION
# // must match. n is a number 1 -> totalNumberOfOptionalClauses.
#
# optional_condition1 clause
# optional_condition2 clause
# ...
#
#
# :OPTIONAL_SECTION :n // You can have more than one OPTIONAL_SECTION, but all OPTIONAL_SECTIONs must be
# // satisfied in their own right, for the current data value to be considered in class.
#
# optional_condition1 clause
# optional_condition2 clause
# ...
#
# // Currently allowable clauses are listed below.
#
# LEGAL_PATTERN[_IGNORE_CASE]="regExp" // Data value is in class if it matches the regular expression regExp.
# LEGAL_PATTERN_FILE[_IGNORE_CASE]="fileName" // Data value is in class if it matches any regular expression
# // pattern specified in the list file fileName. (Filename only. The list File must exist in the ListFiles Directory).
# LEGAL_VALUE[_IGNORE_CASE]="dataValue" // Data value is in class if it matches the value in dataValue.
# LEGAL_VALUE_FILE[_IGNORE_CASE]="fileName" // Data value is in class if it matches any value contained in list file fileName. (Filename only. The list File must exist in the ListFiles Directory).
#
# ---------------------------------
:MANDATORY_SECTION - All must match
# ---------------------------------
LEGAL_PATTERN_FILE_IGNORE_CASE="LegalPatternsForUKPostCodes.txt"
# --------------------------------------
:OPTIONAL_SECTION :1
# --------------------------------------
LEGAL_PATTERN_IGNORE_CASE="[A-Z][1-9][1-9][A-Z][A-Z]"
LEGAL_PATTERN_IGNORE_CASE="[A-Z][1-9] [1-9][A-Z][A-Z]"
LEGAL_PATTERN_IGNORE_CASE="[A-Z][A-Z][1-9][1-9][A-Z][A-Z]"
LEGAL_PATTERN_IGNORE_CASE="[A-Z][A-Z][1-9] [1-9][A-Z][A-Z]"
LEGAL_PATTERN_IGNORE_CASE="[A-Z][A-Z][1-9][0-9][1-9][A-Z][A-Z]"
LEGAL_PATTERN_IGNORE_CASE="[A-Z][A-Z][1-9][0-9] [1-9][A-Z][A-Z]"