From e581f8f0f0a23f17056222d398151b565c15c4af Mon Sep 17 00:00:00 2001 From: Gautier DI FOLCO Date: Mon, 2 Oct 2023 00:25:06 +0200 Subject: [PATCH] fixup! Add Workspace name validation (#834) --- src/Monocle/Config.hs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Monocle/Config.hs b/src/Monocle/Config.hs index f0e058253..b417d99d1 100644 --- a/src/Monocle/Config.hs +++ b/src/Monocle/Config.hs @@ -481,14 +481,14 @@ getIdentByAliasFromIdents alias idents' = case find isMatched idents' of isMatched Ident {..} = alias `elem` aliases mkIndexName :: Text -> Either Text IndexName -mkIndexName x = do +mkIndexName name = do let check name p = if p then Right () else Left name - check "Is empty" $ not $ T.null x - check "Is longer than 255 bytes" $ BS.length (T.encodeUtf8 x) < 256 - check "Contains uppercase letter(s)" $ T.all (\x -> not (isLetter x) || isLowerCase x) x - check "Includes [\\/*?\"<>| ,#:]" $ T.all (flip @_ @String notElem "\\/*?\"<>| ,#:") x - check "Starts with [-_+.]" $ maybe False (flip @_ @String notElem "-_+." . fst) $ T.uncons x - check "Is (.|..)" $ notElem x [".", ".."] - return $ IndexName x + check "Is empty" $ not $ T.null name + check "Is longer than 255 bytes" $ BS.length (T.encodeUtf8 name) < 256 + check "Contains uppercase letter(s)" $ T.all (\x -> not (isLetter x) || isLowerCase x) name + check "Includes [\\/*?\"<>| ,#:]" $ T.all (flip @_ @String notElem "\\/*?\"<>| ,#:") name + check "Starts with [-_+.]" $ maybe False (flip @_ @String notElem "-_+." . fst) $ T.uncons name + check "Is (.|..)" $ notElem name [".", ".."] + return $ IndexName name -- End - Some utility functions