Skip to content

Commit

Permalink
fixup! Add Workspace name validation (#834)
Browse files Browse the repository at this point in the history
  • Loading branch information
blackheaven committed Oct 1, 2023
1 parent 2c14024 commit e581f8f
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/Monocle/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit e581f8f

Please sign in to comment.