Elektra  0.8.23
Plugin: range

The range plugin checks if a Key's value is within a given range.

Usage

The plugin checks every Key in the KeySet for the metakey check/range which contains either a single range with the syntax [-]min-[-]max, or a list of ranges or values separated by , and tests if the Key's value is within the range(s).

check/type can be used to specify the data type. If not specified otherwise the default value is long long

Possible values:

Dependencies

None.

Examples

1 # Backup-and-Restore:/examples/range
2 
3 sudo kdb mount range.ecf /examples/range range dump
4 
5 # should succeed
6 kdb set /examples/range/value 5
7 kdb setmeta /examples/range/value check/range "1-10"
8 # RET: 0
9 
10 # should fail
11 kdb set /examples/range/value 11
12 # RET:5
13 
14 # should also fail
15 kdb set /examples/range/value "\-1"
16 # RET:5
17 
18 # we can also allow only individual values:
19 kdb setmeta /examples/range/value check/range "1,2,4,8"
20 
21 kdb set /examples/range/value 7
22 # RET:5
23 
24 kdb set /examples/range/value 2
25 # RET:0
26 
27 kdb rm -r /examples/range
28 sudo kdb umount /examples/range

Limitations

None.