From 52fd80748d95b522561a477a1869d6923516f633 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 7 Feb 2016 05:08:32 +0100 Subject: krebs.types.{hostname,label}: check RFC952 --- krebs/4lib/types.nix | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'krebs/4lib') diff --git a/krebs/4lib/types.nix b/krebs/4lib/types.nix index f9150379..52eb764e 100644 --- a/krebs/4lib/types.nix +++ b/krebs/4lib/types.nix @@ -175,8 +175,6 @@ types // rec { addr = str; addr4 = str; addr6 = str; - hostname = str; - label = str; krebs.file-location = types.submodule { options = { @@ -195,6 +193,22 @@ types // rec { }; }; + # RFC952, B. Lexical grammar, + hostname = mkOptionType { + name = "hostname"; + check = x: all label.check (splitString "." x); + merge = mergeOneOption; + }; + + # RFC952, B. Lexical grammar, + # RFC1123, 2.1 Host Names and Numbers + label = mkOptionType { + name = "label"; + # TODO case-insensitive labels + check = x: match "[0-9A-Za-z]([0-9A-Za-z-]*[0-9A-Za-z])?" x != null; + merge = mergeOneOption; + }; + # POSIX.1‐2013, 3.278 Portable Filename Character Set filename = mkOptionType { name = "POSIX filename"; -- cgit v1.2.3