lib/types: add intBetween
An int type that checks the value range.
This commit is contained in:
parent
cdbe4671be
commit
c53d874277
@ -114,6 +114,12 @@ rec {
|
||||
merge = mergeOneOption;
|
||||
};
|
||||
|
||||
intBetween = min: max:
|
||||
addCheck types.int (x: x >= min && x <= max) // {
|
||||
name = "intBetween";
|
||||
description = "integer between ${toString min} and ${toString max} (both inclusively)";
|
||||
};
|
||||
|
||||
str = mkOptionType {
|
||||
name = "str";
|
||||
description = "string";
|
||||
|
@ -26,6 +26,17 @@
|
||||
<term><varname>types.int</varname></term>
|
||||
<listitem><para>An integer.</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<varname>types.intBetween</varname>
|
||||
<replaceable>min</replaceable>
|
||||
<replaceable>max</replaceable>
|
||||
</term>
|
||||
<listitem><para>An integer between <replaceable>min</replaceable>
|
||||
and <replaceable>max</replaceable> (both inclusive).
|
||||
Useful for e.g. port ranges.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>types.path</varname></term>
|
||||
<listitem><para>A filesystem path, defined as anything that when coerced to
|
||||
|
Loading…
Reference in New Issue
Block a user