forked from mirrors/nixpkgs
nixpkgs.lib: Add types.strMatching
This commit is contained in:
parent
6281eb123b
commit
83048c4fe0
|
@ -174,6 +174,13 @@ rec {
|
||||||
merge = mergeOneOption;
|
merge = mergeOneOption;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
strMatching = pattern: mkOptionType {
|
||||||
|
name = "strMatching ${escapeNixString pattern}";
|
||||||
|
description = "string matching the pattern ${pattern}";
|
||||||
|
check = x: str.check x && builtins.match pattern x != null;
|
||||||
|
inherit (str) merge;
|
||||||
|
};
|
||||||
|
|
||||||
# Merge multiple definitions by concatenating them (with the given
|
# Merge multiple definitions by concatenating them (with the given
|
||||||
# separator between the values).
|
# separator between the values).
|
||||||
separatedString = sep: mkOptionType rec {
|
separatedString = sep: mkOptionType rec {
|
||||||
|
|
|
@ -110,6 +110,12 @@
|
||||||
<listitem><para>A string. Multiple definitions are concatenated with a
|
<listitem><para>A string. Multiple definitions are concatenated with a
|
||||||
collon <literal>":"</literal>.</para></listitem>
|
collon <literal>":"</literal>.</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term><varname>types.strMatching</varname></term>
|
||||||
|
<listitem><para>A string matching a specific regular expression. Multiple
|
||||||
|
definitions cannot be merged. The regular expression is processed using
|
||||||
|
<literal>builtins.match</literal>.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
</variablelist>
|
</variablelist>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
Loading…
Reference in a new issue