Rules and rule clauses
A rule checks one condition on the notice, in the context of its rule-set. It is made of clauses that always come
in the same order: an optional WHEN clause, an ASSERT or REPORT clause, the AS, FOR and IN clauses, and
an optional SCOPE clause. The last rule of a rule-set can start with OTHERWISE instead of WHEN. This page
describes the rule as a whole, and then each of its clauses.
Rule
A rule states a condition that the notice must meet, or a situation that the validation must report. It also gives the information needed to report a problem: its severity, the identifier of the rule, the field or node concerned, and the notice subtypes to which the rule applies.
<test> AS <severity> <rule-identifier> FOR <target> IN <notice-subtypes>; <test> AS <severity> <rule-identifier> FOR <target> IN <notice-subtypes> SCOPE <scope>;
- <test>
-
what the rule checks, in one of the following forms:
-
ASSERT <condition>orREPORT <condition>(seeASSERTclause andREPORTclause); -
WHEN <precondition> ASSERT <condition>orWHEN <precondition> REPORT <condition>(seeWHENclause); -
OTHERWISE ASSERT <condition>orOTHERWISE REPORT <condition>, for the last rule of a rule-set (seeOTHERWISEclause).
-
- <severity>, <rule-identifier>
-
the severity of the findings and the identifier of the rule (see
ASclause). - <target>
-
the field or node that the rule validates (see
FORclause). - <notice-subtypes>
-
the notice subtypes to which the rule applies (see
INclause). - <scope>
-
optional. The kind of validation to which the rule is limited, and a flag (see
SCOPEclause).
The validation evaluates a rule for each occurrence that the context of its rule-set matches, in the notices whose
subtype is listed in its IN clause. When a rule finds a problem, the validation records a finding. A finding is
an entry of the validation report. It gives the identifier of the rule, its severity, its message, its target, and
the place in the notice where the validation found the problem.
Whether a rule finds a problem depends on its test:
-
With
ASSERT, the condition must be true. The validation records a finding when it is false. -
With
REPORT, the validation records a finding when the condition is true. -
With a
WHENclause, the rule applies only to the occurrences for which the precondition is true. -
With
OTHERWISE, the rule applies only to the occurrences for which none of the preconditions of the rule-set is true.
The message of a finding is the label rule|text|<rule-identifier> (see
AS clause).
The clauses of a rule must come in the order shown. The rule ends with a semicolon, after its IN clause or its
SCOPE clause. You can choose line breaks and indentation between the clauses freely, and write a comment after any
clause. The SDK writes each clause on a line of its own.
Restrictions
-
You must write the
AS,FORandINclauses, and the semicolon that ends the rule. -
The condition and the precondition must be expressions of type indicator.
Examples
WITH ND-Root
ASSERT BT-00-EndDate >= BT-00-StartDate
AS ERROR R-W1D-J2Y
FOR BT-00-EndDate
IN *;
WHEN BT-00-Indicator == TRUE
ASSERT BT-00-Number is present
AS ERROR R-M3C-U8N
FOR BT-00-Number
IN 1-5, E1
SCOPE @POST;
The first rule requires, in every notice, that the end date is not earlier than the start date. The second rule uses all the optional clauses. It requires a number when the indicator is true, in the notices of subtypes 1 to 5 and E1, and only in the validation of the complete notice.
WITH ND-Root ASSERT BT-00-EndDate >= BT-00-StartDate AS ERROR R-W1D-J2Y FOR BT-00-EndDate IN *;
The first rule of the previous example, written on one line.
| EFX-1 had no rules. The SDK provided the validation rules as Schematron files. The field metadata contained constraints, which combined an EFX-1 condition and an EFX-1 assertion with a severity, a message and a list of notice subtypes. |
See also: Rule-set,
WITH clause,
Rules file
WHEN clause
The WHEN clause makes a rule conditional: the rule applies only to the occurrences for which the precondition of
the WHEN clause is true.
WHEN <precondition> ASSERT <condition> <other-clauses> WHEN <precondition> REPORT <condition> <other-clauses>
- <precondition>
-
an expression of type indicator.
- <condition>
-
the condition of the
ASSERTorREPORTclause. - <other-clauses>
-
the
AS,FORandINclauses, optionally theSCOPEclause, and the semicolon that ends the rule (see Rule).
For each occurrence that the context matches, the validation evaluates the precondition first. When it is true,
the validation checks the rule as if it had no WHEN clause. When it is false, the rule does not apply to the
occurrence and records no finding, whatever the value of its condition.
A WHEN clause belongs only to the rule that it starts. The conditional rules of a rule-set do not depend on each
other. The validation evaluates each precondition on its own, and several conditional rules can apply to the same
occurrence. They do not form a chain of alternatives. For a rule that applies when none of the preconditions is
true, use OTHERWISE (see OTHERWISE clause).
The IN clause of a rule, not a precondition, gives the notice subtypes to which the rule applies (see
IN clause).
Restrictions
-
The precondition must be a single value of type indicator (see Type checking).
-
A rule has at most one
WHENclause. To combine several conditions, use the logical operators (see Logical operators).
Examples
WITH ND-Root
WHEN BT-00-Indicator == TRUE
ASSERT BT-00-Number is present
AS ERROR R-S9L-R5K
FOR BT-00-Number
IN *;
WHEN BT-00-Indicator == FALSE
ASSERT BT-00-Number is not present
AS ERROR R-V4T-O7J
FOR BT-00-Number
IN *;
Two conditional rules: the number is required when the indicator is true, and forbidden when it is false.
validation/stage-4m.efx)WITH ND-LotTender
WHEN OPT-321-Tender in $global-ten-clos-nw
ASSERT BT-193-Tender is not present
AS ERROR R-UX9-G3Z
FOR BT-193-Tender
IN 29-37,E4,E5;
WHEN not(OPT-321-Tender in $global-ten-clos-nw)
ASSERT BT-193-Tender is present
AS ERROR R-RXE-7FY
FOR BT-193-Tender
IN 30;
Two conditional rules whose preconditions use a stage variable. The SDK writes the WHEN clause on its own line,
with the same indentation as the ASSERT clause.
| In EFX-1, the constraints of the field metadata could have a condition, written as a separate EFX-1 expression. |
See also: OTHERWISE clause,
Rule,
Conditional display
ASSERT clause
The ASSERT clause states a condition that the notice must meet. The rule records a finding when the condition is
false.
ASSERT <condition> ASSERT <semantic-assertion>
- <condition>
-
an expression of type indicator, which is true when the notice meets the rule.
- <semantic-assertion>
-
instead of a condition, a statement about the
FORtarget of the rule, such asIS NOT EMPTY(see Semantic assertion).
For each occurrence to which the rule applies, the validation evaluates the condition in the context of that occurrence. When the condition is true, the notice meets the rule, and the validation records nothing. When it is false, the rule records a finding with the severity, identifier and target given by its other clauses.
The condition can be any expression of type indicator: a comparison, a presence condition, a function call, a logical combination of these, and so on (see Comparison operators and Presence). It can call dynamic functions (see Dynamic function declaration).
Restrictions
-
The condition must be a single value of type indicator.
Examples
WITH ND-Root
ASSERT BT-00-Text is present
AS ERROR R-K7P-M2Q
FOR BT-00-Text
IN *;
ASSERT BT-00-EndDate >= BT-00-StartDate
AS ERROR R-W1D-J2Y
FOR BT-00-EndDate
IN *;
ASSERT BT-13-Text has no duplicates
AS WARNING R-E3F-L2G
FOR BT-13-Text
IN *;
Three rules: a field must be present, the end date must not be earlier than the start date, and the values of a repeatable field must all be different.
See also: REPORT clause,
Rule,
Indicator
Semantic assertion
A semantic assertion states, in a few fixed words, what the rule requires of the field or node that it validates,
such as "it is mandatory" or "its value has at most 100 characters". You write it after ASSERT, in the place of a
condition.
ASSERT IS NOT EMPTY ASSERT IS NOT PRESENT ASSERT NOT REPEATED ASSERT NOT MODIFIED VIA <condition> ASSERT NOT ADDED VIA <condition> ASSERT NOT REMOVED VIA <condition> ASSERT OCCURS <comparison-operator> <integer> ASSERT OCCURS BETWEEN <integer> AND <integer> ASSERT LENGTH <comparison-operator> <integer> ASSERT LENGTH BETWEEN <integer> AND <integer> ASSERT VALUE <comparison-operator> <number> ASSERT VALUE BETWEEN <number> AND <number> ASSERT IN [...<codelist-identifier>] ASSERT LIKE '<pattern>'
- <comparison-operator>
-
==,!=,<,<=,>or>=(see Comparison operators). - <integer>
-
a whole number written with digits, such as
2or100. - <number>
-
a number literal, such as
0,-5or9999.99(see Number literal). - <codelist-identifier>
-
the identifier of a codelist (see Codelist reference).
- <pattern>
-
a regular expression (see Regular expressions).
- <condition>
-
an expression of type indicator: the check that the validation runs.
Why semantic assertions exist. The condition of an ordinary ASSERT is an expression that the validation
evaluates on its own. It can refer to any fields, and it does not have to concern the FOR target of the rule, which
only shows where to report a finding. ASSERT BT-00-EndDate >= BT-00-StartDate … FOR BT-00-EndDate is true or
false, but it does not state what the rule requires of the end date. So an application in which a user fills in a
notice, such as a form in a browser, cannot tell what the condition means for the field that it displays.
A semantic assertion, on the other hand, always concerns the target itself. It states the value of one property of
the form field in which the user enters the target, such as "mandatory", "forbidden", "at most 100 characters" or
"one of the codes of this codelist". When the rule has a WHEN clause, that value depends on its condition. For
example, WHEN BT-00-Indicator == TRUE ASSERT IS NOT EMPTY … FOR BT-00-Text tells the application that the form
field of BT-00-Text is mandatory whenever the indicator is true.
The application can then set up its form fields, and adapt them as the user fills in the form. It marks the field as mandatory, limits the number of characters that the user can type, or offers only the codes of the codelist. In this way, the application prevents mistakes while the user enters the data, instead of reporting them after the user submits the notice.
The validation checks a semantic assertion as it checks any other rule, so a notice that does not meet it still
receives a finding. You could reach the same validation result with an ordinary condition, such as
BT-00-Text is present instead of IS NOT EMPTY. What a semantic assertion adds is that the application can prevent
the mistake before the notice is validated.
A semantic assertion applies to the FOR target of its rule, read from the context of the rule (see
FOR clause). It names no field or node of its
own. It means:
| Semantic assertion | The target … |
|---|---|
|
is mandatory: it must be in the notice. |
|
is forbidden: it must not be in the notice. |
|
appears at most once. |
|
keeps the value it had in an earlier notice, such as the notice that this one changes. |
|
has no occurrence that an earlier notice did not have. |
|
keeps every occurrence that an earlier notice had. |
|
appears a number of times that meets the comparison, or is between the two numbers. |
|
has a value whose number of characters meets the comparison, or is between the two numbers. |
|
has a numeric value that meets the comparison, or is between the two numbers. |
|
has a value that is one of the codes of the codelist. EFX first converts a value that is not a text to text, as the
function |
|
has a value that matches the pattern, as it is written in the notice (also when the field is a number or a date). |
With BETWEEN, both numbers are included: LENGTH BETWEEN 2 AND 100 accepts 2 and 100 characters. The first number
is the lower limit, and the second the upper limit. When they are equal, BETWEEN requires exactly that number:
OCCURS BETWEEN 2 AND 2 means that the target appears exactly twice.
NOT MODIFIED, NOT ADDED and NOT REMOVED compare the notice with an earlier one, which the rule cannot read
directly. So VIA follows them, with the condition that the validation checks. This is usually a call of a dynamic
function that asks an external service (see
Dynamic function declaration).
The application in which the user fills in the notice uses the semantic assertion, and the WHEN clause of the rule,
to know when the target cannot change. It does not need the condition after VIA. The translator accepts any
condition of type indicator after VIA, and does not check that the condition calls a dynamic function.
You can combine a semantic assertion with a WHEN clause, and write it after OTHERWISE ASSERT. So you write a field
that is mandatory under a condition and forbidden otherwise as a pair of rules, which the application reads together
(see the last example).
The words of semantic assertions are keywords, which you write in upper case: IS, NOT, EMPTY, PRESENT,
REPEATED, MODIFIED, ADDED, REMOVED, VIA, OCCURS, LENGTH, VALUE, BETWEEN, AND and LIKE.
Restrictions
-
You can write a semantic assertion only after
ASSERTorOTHERWISE ASSERT.REPORT IS NOT EMPTYis an error. -
A semantic assertion is the whole clause: it cannot be combined with an expression, as in
ASSERT IS NOT EMPTY and BT-00-Number > 0. -
NOT MODIFIED,NOT ADDEDandNOT REMOVEDmust be followed byVIAand a condition. -
After
OCCURSandLENGTH, the numbers are whole numbers:OCCURS >= 1.5is an error. AfterVALUE, the numbers are number literals:VALUE >= 2020-01-01Zis an error. -
With
BETWEEN, the first number cannot be greater than the second.LENGTH BETWEEN 9 AND 2is an error, because no value could ever meet it. The translator compares the numbers by their value, however you write them, soVALUE BETWEEN 1.0 AND .5is an error too. -
The target must have a type that the semantic assertion accepts:
LENGTHneeds a field of type text (also a code, a URL or an identifier), andVALUEa field of type number (also an integer, an amount or a measure).VALUE >= 0for a text, date or duration field, andLENGTH <= 3for a number field, are errors. -
LENGTH,VALUE,INandLIKEneed a target that has one value in the context of the rule: a node, or a repeatable field read from a parent context, is an error, as inWITH ND-Root ASSERT LENGTH <= 3 … FOR BT-00-Repeatable-Text. A multilingual field has one value for each language, so it counts as several values. Write the rule with the field as its context, as inWITH BT-00-Text-Multilingual ASSERT LENGTH <= 100 ….IS NOT EMPTY,IS NOT PRESENT,NOT REPEATEDandOCCURSaccept any field or node. -
The pattern of
LIKEfollows the rules of regular expressions in EFX. -
You write the keywords in upper case:
ASSERT is not emptyis an error.
Examples
WITH ND-Root
ASSERT IS NOT EMPTY AS ERROR R-K7P-M2Q FOR BT-00-Text IN *;
ASSERT LENGTH <= 100 AS ERROR R-W1D-J2Y FOR BT-00-Text IN *;
ASSERT LIKE '^[0-9]+$' AS WARNING R-E3F-L2G FOR BT-00-Text IN *;
Three rules on the same field: it is mandatory, it has at most 100 characters, and it contains digits only.
WITH ND-Root
ASSERT OCCURS BETWEEN 1 AND 3 AS ERROR R-K7P-M2Q FOR BT-00-Repeatable-Text IN *;
ASSERT VALUE BETWEEN 0.5 AND 9999 AS ERROR R-W1D-J2Y FOR BT-00-Number IN *;
ASSERT IN [...accessibility] AS ERROR R-E3F-L2G FOR BT-00-Code IN *;
A repeatable field that appears one to three times, a number between 0.5 and 9999, and a code of a codelist.
WITH ND-Root
WHEN BT-00-Indicator == TRUE ASSERT IS NOT EMPTY AS ERROR R-K7P-M2Q FOR BT-00-Text IN *;
OTHERWISE ASSERT IS NOT PRESENT AS ERROR R-K7P-M2R FOR BT-00-Text IN *;
A field that is mandatory when the indicator is true, and forbidden otherwise.
ENDPOINT "default" AT "https://api.example.org/eforms";
LET dynamic:?is-unchanged(text:$id) CALL API;
---- STAGE 5 ----
WITH ND-Root
ASSERT NOT MODIFIED VIA ?is-unchanged(BT-00-Text)
AS ERROR R-D4K-P9M
FOR BT-00-Text
IN *;
A field whose value cannot change. The validation checks this with a call to the dynamic function
?is-unchanged.
| Semantic assertions are new in EFX-2. |
See also: ASSERT clause,
OTHERWISE clause,
FOR clause
REPORT clause
The REPORT clause states a situation that the validation must report. The rule records a finding when the
condition is true.
REPORT <condition>
- <condition>
-
an expression of type indicator, which is true when the situation to report occurs.
For each occurrence to which the rule applies, the validation evaluates the condition in the context of that occurrence. When the condition is true, the rule records a finding with the severity, identifier and target given by its other clauses. When it is false, the validation records nothing.
REPORT is the opposite of ASSERT: a rule REPORT <condition> records the same findings as a rule
ASSERT not(<condition>). Choose the form that states the requirement most directly: ASSERT states what must be
true, and REPORT states what the validation must point out. You often combine REPORT with the severity WARNING
or INFO, to draw attention to unusual data without making the notice fail validation.
With a WHEN clause, a rule WHEN <precondition> REPORT <condition> records a finding when both the precondition and
the condition are true.
Restrictions
-
The condition must be a single value of type indicator.
Examples
WITH ND-Root
REPORT BT-00-Number > 1000000
AS WARNING R-A8Q-H3W
FOR BT-00-Number
IN *;
REPORT BT-00-EndDate < BT-00-StartDate
AS ERROR R-P9C-W5Y
FOR BT-00-EndDate
IN *;
The first rule gives a warning for an unusually large number. The second rule reports an error when the end date is earlier than the start date.
WITH ND-Root
WHEN BT-00-Indicator == TRUE
REPORT BT-00-Number is not present
AS WARNING R-P9C-W5Z
FOR BT-00-Number
IN *;
A warning when the indicator is true and the number is missing.
See also: ASSERT clause,
AS clause,
not
OTHERWISE clause
OTHERWISE starts a fallback rule: the last rule of a rule-set whose other rules all have a WHEN clause. The
fallback rule applies to the occurrences for which none of the preconditions of the rule-set is true.
OTHERWISE ASSERT <condition> <other-clauses> OTHERWISE ASSERT <semantic-assertion> <other-clauses> OTHERWISE REPORT <condition> <other-clauses>
- <condition>
-
the condition of the
ASSERTorREPORTclause. - <semantic-assertion>
-
after
OTHERWISE ASSERT, a semantic assertion can take the place of the condition (see Semantic assertion). - <other-clauses>
-
the
AS,FORandINclauses, optionally theSCOPEclause, and the semicolon that ends the rule (see Rule).
For each occurrence that the context matches, the fallback rule applies when the preconditions of all the
conditional rules of the rule-set are false for that occurrence. The validation then checks it like a rule without a
WHEN clause. When at least one precondition is true, the fallback rule does not apply.
The preconditions of all the conditional rules of the rule-set count. This includes the preconditions of rules whose
IN clause does not include the subtype of the notice under validation. The fallback rule has its own AS, FOR,
IN and SCOPE clauses.
You can put spaces and line breaks between OTHERWISE and the ASSERT or REPORT keyword that follows it, but not
a comment. You write these keywords in upper case.
Restrictions
-
A fallback rule is allowed only in a rule-set in which every other rule has a
WHENclause. -
A rule-set has at most one fallback rule, and it is the last rule of the rule-set.
-
No comment can appear between
OTHERWISEand theASSERTorREPORTkeyword that follows it.
Examples
WITH ND-Root
WHEN BT-00-Code == 'code1'
ASSERT BT-00-Number > 0
AS ERROR R-G2M-X6D
FOR BT-00-Number
IN *;
WHEN BT-00-Code == 'code2'
ASSERT BT-00-Number == 0
AS ERROR R-J5B-Y9S
FOR BT-00-Number
IN *;
OTHERWISE ASSERT BT-00-Number is not present
AS ERROR R-C1V-Z4H
FOR BT-00-Number
IN *;
When the code is code1, the number must be positive. When it is code2, the number must be zero. In all other
cases, the number must be absent.
WITH ND-RepeatableNode
WHEN BT-00-Number-In-Repeatable-Node > 100
ASSERT BT-00-Text-In-Repeatable-Node is present
AS ERROR R-T6N-K8R
FOR BT-00-Text-In-Repeatable-Node
IN 1-5;
OTHERWISE
ASSERT BT-00-Date-In-Repeatable-Node is present
AS WARNING R-E3F-L2G
FOR BT-00-Date-In-Repeatable-Node
IN *;
OTHERWISE on a line of its own. In a notice of subtype 9, the validation does not check the conditional rule, but
its precondition still decides whether the fallback rule applies.
See also: WHEN clause,
Rule-set
AS clause
The AS clause gives the severity of the findings of a rule and the identifier of the rule.
AS ERROR <rule-identifier> AS WARNING <rule-identifier> AS INFO <rule-identifier>
- <rule-identifier>
-
the identifier of the rule: an upper-case
R, a hyphen, three letters or digits, a hyphen and three letters or digits, for exampleR-K7P-M2Q.
The severity shows how serious the findings of the rule are:
-
ERROR: the notice does not meet a rule that it must meet. A finding with this severity makes the notice fail validation. -
WARNING: the finding draws attention to a possible problem. It does not make the notice fail validation. -
INFO: the finding gives information. It does not make the notice fail validation.
The rule identifier names the rule in the findings that it produces. It also selects the message of these
findings: the message is the text of the label rule|text|<rule-identifier> (see
Label block). For example, the SDK file
translations/rule_en.xml gives the English text of the label rule|text|R-Y3J-IEW. Each rule should have its
own identifier, but EFX does not check that no identifier is used twice. The SDK writes the letters of rule
identifiers in upper case.
Restrictions
-
The severity is
ERROR,WARNINGorINFO, in upper case. -
The rule identifier has exactly the form described above.
Examples
WITH ND-Root
ASSERT BT-00-Text is present
AS ERROR R-K7P-M2Q
FOR BT-00-Text
IN *;
ASSERT string-length(BT-00-Text) <= 200
AS WARNING R-X3F-N8W
FOR BT-00-Text
IN *;
REPORT BT-00-Indicator == FALSE
AS INFO R-H9T-V5L
FOR BT-00-Indicator
IN *;
Three rules with the three severities.
validation/stage-4m.efx) AS ERROR R-ITV-OQC // BR-BT-00720-0052
The comment records the identifier that the same rule had in SDK 1.
EFX-1 had no AS clause. In SDK 1, rule identifiers had a different form, for example BR-BT-00720-0052, and
they were not part of EFX.
|
See also: Rule, Dynamic function declaration, Identifiers
FOR clause
The FOR clause names the field or node that a rule validates: the target of the rule.
FOR <field-identifier> FOR <node-identifier>
- <field-identifier>
-
the identifier of a field, for example
BT-00-Number. - <node-identifier>
-
the identifier of a node, for example
ND-RepeatableNode.
Each finding of a rule refers to its target. Applications use the target to show the message next to the matching input field, or group of fields, of a notice form.
The target does not change where the validation evaluates the rule: the context of the rule-set decides that. The target is usually the field or node that the condition is about, but it can be any field or node.
The target also links each rule to the data that it depends on. For each rule, the translator records the fields and
nodes to which the rule refers, with its target. A notice editor uses this information to check the rules concerned
again when a value changes while the user fills in a notice. This information leaves out the rules limited to the
validation of complete notices (SCOPE @POST).
You write the keyword FOR in upper case. In lower case, for is the keyword of iterations (see
Iteration).
Restrictions
-
The target is only a field identifier or a node identifier. It cannot have a predicate, be an absolute reference or use a context override.
-
The target must be a field or node defined in the SDK.
Examples
WITH ND-Root
ASSERT ND-RepeatableNode is present
AS ERROR R-T6N-K8R
FOR ND-RepeatableNode
IN 1-5;
ASSERT BT-13-Text is not present
AS ERROR R-E3F-L2G
FOR BT-13-Text
IN 9-11;
Two rules evaluated in the context of the root of the notice. The findings of the first refer to a node, and those of the second to a field.
WITH BT-13-Text
ASSERT string-length(BT-13-Text) <= 100
AS ERROR R-B6J-C4R
FOR BT-13-Text
IN *;
A rule whose target is also its context.
See also: Rule,
WITH clause,
Field,
Node
IN clause
The IN clause lists the notice subtypes to which a rule applies.
IN * IN ANY IN <notice-subtypes>, <notice-subtypes>, …
- <notice-subtypes>
-
a notice subtype identifier, such as
16,E1orX01, or a range: two notice subtype identifiers joined by a hyphen, such as1-6orE3-E6.
When the validation checks a notice, it checks a rule only if the subtype of the notice is listed in the IN
clause of the rule. * and ANY stand for all notice subtypes.
A range includes its two ends and all the notice subtypes between them, in the order in which the SDK defines them.
This order is: first the notice subtypes without a letter prefix, in the order of their numbers, then the notice
subtypes with a letter prefix, grouped by prefix in alphabetical order. For example: 1 to 40, CEI, E1 to E6, T01,
T02, X01 and X02. A range covers only notice subtypes that exist: if the SDK has no notice subtype 7, the range 5-9
covers 5, 6, 8 and 9.
You write notice subtype identifiers exactly as in the SDK, with the zeros at the start: X01, not X1. You can put
spaces around the commas and hyphens, and a list can continue over several lines. A range whose ends have different
prefixes, such as E2-X01, is accepted, and covers all the notice subtypes between its ends. The SDK keeps both ends
of each range within the same prefix.
You write the keyword IN in upper case. In lower case, in is the membership operator (see
Membership). You also write the keyword
ANY in upper case.
Restrictions
-
You must write the
INclause. -
Each notice subtype identifier must be a notice subtype defined in the SDK.
-
The first end of a range cannot come after the second, in the order described above.
-
*andANYcannot be combined with other notice subtypes.
Examples
IN *
All notice subtypes.
IN 1, 2, E1
Notice subtypes 1, 2 and E1.
IN 1-5, 9-11, E1-E2, X01
Three ranges and one notice subtype.
validation/stage-1a.efx) ASSERT ND-Lot is not present
AS ERROR R-TMP-002
FOR ND-Lot
IN 1-6,E2,X01,X02;
ASSERT ND-Lot is present
AS ERROR R-TMP-003
FOR ND-Lot
IN 7-40,E3-E6,T01,T02;
Two rules that apply to complementary groups of notice subtypes.
EFX-1 had no IN clause. In SDK 1, the field metadata listed the notice subtypes to which each constraint applied.
|
See also: Rule,
WHEN clause
SCOPE clause
The SCOPE clause limits a rule to one kind of validation. It can also add a flag that classifies the rule.
SCOPE @PRE SCOPE @POST SCOPE #<flag> SCOPE @PRE #<flag> SCOPE @POST #<flag> SCOPE #<flag> @PRE SCOPE #<flag> @POST
- <flag>
-
the name of the flag, for example
lawfulness(see Identifiers).
The validation of notices happens in two situations:
-
while a user fills in a notice, for example in a notice editor;
-
when the notice is complete, for example after the user submits it for publication.
By default, the validation checks a rule in both situations. The scope annotations limit a rule to one of them:
-
@PRE: the validation checks the rule only while the user fills in the notice, and not when it validates the complete notice. -
@POST: the validation checks the rule only when it validates the complete notice, and not while the user fills in the notice.
A flag classifies the rule. It does not change how the validation evaluates the rule. The validation report gives the flag with each finding of the rule, so that you can group or filter the findings.
The SCOPE clause is optional. When there is one, it is the last clause of the rule. It contains a scope annotation,
a flag, or both, in either order. You write the keywords SCOPE, @PRE and @POST in upper case.
Restrictions
-
The
SCOPEclause contains at least a scope annotation or a flag. -
It contains at most one scope annotation (
@PREor@POST) and at most one flag. -
The flag name starts with a letter or an underscore.
Examples
WITH ND-Root
ASSERT BT-00-Text is present
AS ERROR R-K7P-M2Q
FOR BT-00-Text
IN *
SCOPE @PRE;
ASSERT BT-00-Code in ['code1', 'code2']
AS ERROR R-X3F-N8W
FOR BT-00-Code
IN 1-5
SCOPE @POST;
ASSERT BT-00-EndDate >= BT-00-StartDate
AS ERROR R-W1D-J2Y
FOR BT-00-EndDate
IN *
SCOPE @POST #lawfulness;
The validation checks the first rule only while the user fills in the notice, and the other two only when it
validates the complete notice. The findings of the third rule carry the flag lawfulness.
validation/rules.efx)WITH BT-105-Procedure
ASSERT BT-105-Procedure in [...procedure-type-10]
AS ERROR R-K2X-XTF
FOR BT-105-Procedure
IN 10
SCOPE @POST;
A rule that the validation checks only when it validates the complete notice.
The SCOPE clause is new in EFX-2.
|
See also: Rule,
FOR clause