mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-10-03 13:30:36 +00:00
nixpkgs.lib: Add types.strMatching
(cherry picked from commit 83048c4fe0)
This commit is contained in:
committed by
Andreas Rammhold
parent
2c5e616b58
commit
5ce2352f8b
@@ -121,6 +121,13 @@ rec {
|
||||
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
|
||||
# separator between the values).
|
||||
separatedString = sep: mkOptionType rec {
|
||||
|
||||
@@ -62,6 +62,12 @@
|
||||
<listitem><para>A string. Multiple definitions are concatenated with a
|
||||
collon <literal>":"</literal>.</para></listitem>
|
||||
</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>
|
||||
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user