IsNum
All validation programs
Checks a value and takes action if:
-
It consists entirely of numbers
-
It has a specific number of decimal places
-
It has leading and/or trailing signs
-
You want to specify certain decimal requirements.
Format of Parameters
Value (DecPlaceArg) (IfTrueAction) (IfFalseAction)
Where:
Value
|
The value being checked. This can be a variable, Current_Element, or a literal in double quotes. |
DecPlaceArg
|
Optional. Check for number of decimal places, leading and/or trailing signs, and decimal place character requirements. DecPlaceArg can be a constant in double quotes or a variable containing an option string. It is made up of one or more of the following sequences: Dn(-n) – Check the for a an allowable number of decimal places. S or T – Means the value must have a leading (S) or trailing (T) sign for the edit to pass. Otherwise, the IfFalseAction will be taken. If you include a comma or period, the decimal point character will have to be that character. See DecPlaceArg Examples below for additional information. |
IfTrueAction
|
An action to be executed if the value contains all numbers. Required if you are specifying an IfFalseAction. To do nothing if false, use this: (BusinessRules.Utilities DoNothing) |
IfFalseAction
|
Optional. An action to be executed if the value contains something other than numbers. |
Example. This rule checks to see if the current element is entirely numeric. If so, it checks to see that it conforms to the NationalProviderID and displays error 32001 if it does not.
The parameter is:
Current_Element (BusinessRules.Utilities CheckFormat NationalProviderID Current_Element (BusinessRules.Utilities DisplayErrorByNumber 32001) (BusinessRules.Utilities DoNothing))
DecPlaceArg Examples
This section provides examples of the variations of the DecPlaceArg parameter.
-
Dn(-n), checks Value for a an allowable number of decimal places.
Dn, where n is 0 – 9 requires that Value have exactly the specified number of decimal digits. For example, D3 will pass 34.123, but not 34.12 or 55.
D n-n specifies a range and requires that Value have at least the minimum number of decimal places, but no more than the maximum. For example, D2-4 will pass 123.4567 and 44.55, but not 123.4 nor 44.987654.
A number with a decimal point character but no subsequent decimal digits, such as 1234., will always fail.
Examples
IsNum “1234.56” “D2” (IfTrueAction) (IfFalseAction)
Causes the (TrueAction) to be taken because 1234.56 is a number, and has two decimal places.
IsNum “1234.567” “D2” (IfTrueAction)(IfFalseAction)
Causes the (IfFalseAction) to be taken because, while 1234.567 is a number, it has three, not two, decimal places.
-
S or T specifies requirement for sign characters ‘+’ and ‘-’.
Use S to require leading signs in the value (ex. +123, -5.6).
Use T to require trailing signs in the value (ex. 123-, 2.345+).
Use both S and T to require signs before or after the number (ex. +123, 123-). (Note that in this case a value with both will fail.)
Examples
IsNum “+1234.567” “D2-5S”(IfTrueAction)(IfFalseAction)
Causes the (IfTrueAction) to be taken because +1234.567 is a signed number.
IsNum “1234.567” “D2-5S” ”(IfTrueAction)(IfFalseAction)
Causes the (IfFalseAction) to be taken because 1234.567 does not have the required leading sign character.
-
. (period) or , (comma) forces the decimal point character to be the specified one. For example, D2-5, forces the decimal point character to be a comma and D2-5. forces the decimal point character to be a period.
The default decimal point character is determined from the input file if provided (for example, EDIFACT and its UNA segment). Otherwise, the default is a period.
Examples
IsNum “1234,567” “D2-5”(IfTrueAction)(IfFalseAction)
The action taken depends on the decimal point character in effect.
For EDIFACT data, where the decimal point is specified by the UNA as a comma, the (IfTrueAction) is taken.
For X12 data, which assumes a period as the decimal point, the value is not recognized as a number, and the (IfFalseAction) is taken.
IsNum “1234,567” “D2-5, ”(IfTrueAction)(IfFalseAction)
Causes the (IfTrueAction) to be taken because it forces the decimal point to be a comma.