NumberType
The number should match a specific type.
Parameter table
param | unit | required | description |
---|---|---|---|
key | yes | The key of the number to check if it is of a specific type (key ). | |
type | no | The type of the number. Options are: N , N* , Z , Z* , D . | |
decLimit | no | The maximum number of decimal places allowed for the number (decLimit ). |
How to setup
The rule verifies whether the number associated with the specified (key
) is of a specific (type
).
If the number does not meet this criterion, the rule will fail.
The number type can be one of the following:
-
N
: the set of positive integers with addition to 0 and extending indefinitely. In mathematical notation, they are often represented as ℕ = {0, 1, 2, 3, 4, ...}. -
N*
: the set of positive integers starting from 1 and extending indefinitely. In mathematical notation, they are often represented as ℕ* = {1, 2, 3, 4, ...}. -
Z
: the set of integers that includes all positive and negative whole numbers, as well as 0. In mathematical notation, the set is denoted as ℤ = {..., -2, -1, 0, 1, 2, ...}. -
Z*
:the set of integers including all positive and negative whole numbers and excluding 0. In mathematical notation, this set is denoted as ℤ* = {..., -2, -1, 1, 2, ...}. -
D
: Decimal numbers, or real numbers with decimal representations, include both rational and irrational numbers. They can be expressed in the form of a whole number followed by a decimal point and a series of digits. Examples of decimal numbers include 0.5, -3.14159, and 2.75.
For the decimal type, an optional parameter (decLimit
) can be used
to specify the allowed limit of decimal places.
Examples
value | valid | decLimit | type | description |
---|---|---|---|---|
1 | ✅ | N | The number should be a natural number. | |
-1 | ✅ | Z | The number should be an integer. | |
1.1 | ❌ | Z | The number should be an integer. | |
3 | ✅ | N* | The number should be a positive integer. | |
1.23 | ✅ | 2 | D | The number should be a decimal number with a limit of 2 decimal places. |
1 | ✅ | 2 | D | The number should be a decimal number with a limit of 2 decimal places. |
1.234 | ❌ | 2 | D | The number should be a decimal number with a limit of 2 decimal places. |
-1 | ❌ | N* | The number should be a positive integer. | |
0 | ❌ | Z* | The number should be a positive/negative integer. | |
-1 | ✅ | Z* | The number should be a positive/negative integer. | |
1 | ✅ | Z* | The number should be a positive/negative integer. | |
-1 | ❌ | N | The number should be a natural number. | |
1.1 | ❌ | N | The number should be a natural number. | |
1.1 | ✅ | D | The number should be a decimal number. | |
1 | ✅ | D | The number should be a decimal number. |