]> gitweb.michael.orlitzky.com - hath.git/blobdiff - src/Main.hs
Move the is_valid_cidr function in to the Cidr module.
[hath.git] / src / Main.hs
index 7686ae30fb989e0cd3ee51d2dca2ac9e6980629b..7b3bd7b0884847a456545903594130e9a8504539 100644 (file)
@@ -2,10 +2,9 @@ import Data.List (intercalate, intersperse)
 import System.Exit (ExitCode(..), exitWith)
 import System.IO (stderr, hPutStrLn)
 
-import Text.Regex.Posix
-
 import Cidr (Cidr,
              from_string,
+             is_valid_cidr,
              min_first_octet,
              min_second_octet,
              min_third_octet,
@@ -70,11 +69,6 @@ cidr_to_regex cidr =
       max4   = max_fourth_octet cidr
 
 
--- Will return True if the passed String is in CIDR notation, False
--- otherwise.
-is_valid_cidr :: String -> Bool
-is_valid_cidr cidr = cidr =~ "([0-9]{1,3}\\.){3}[0-9]{1,3}/[0-9]{1,2}"
-
 
 -- Take a list of Strings, and return a regular expression matching
 -- any of them.
@@ -95,7 +89,7 @@ numeric_range x y =
 -- Take a CIDR String, and exit with a failure if it's invalid.
 validate_or_die :: String -> IO ()
 validate_or_die cidr = do
-  if (is_valid_cidr cidr)
+  if (Cidr.is_valid_cidr cidr)
     then do
       return ()
     else do