Allow empty matchers

This commit is contained in:
Andrey Kuzmin 2018-03-16 11:19:57 +01:00
parent d63c25a855
commit 1c9034282c
3 changed files with 5 additions and 2 deletions

View File

@ -212,7 +212,7 @@ stringContents separator =
|= keepOne (\char -> True)
, Parser.keep Parser.oneOrMore (\char -> char /= separator && char /= '\\')
]
|> Parser.repeat Parser.oneOrMore
|> Parser.repeat Parser.zeroOrMore
|> Parser.map (String.join "")

View File

@ -155,7 +155,7 @@ parseEndsAt startsAt endsAt =
validateMatcherForm : MatcherForm -> MatcherForm
validateMatcherForm { name, value, isRegex } =
{ name = validate stringNotEmpty name
, value = validate stringNotEmpty value
, value = value
, isRegex = isRegex
}

View File

@ -13,6 +13,9 @@ parseMatcher =
[ test "should parse empty matcher string" <|
\() ->
Expect.equal Nothing (Utils.Filter.parseMatcher "")
, test "should parse empty matcher value" <|
\() ->
Expect.equal (Just (Matcher "alertname" Eq "")) (Utils.Filter.parseMatcher "alertname=\"\"")
, fuzz (tuple ( string, string )) "should parse random matcher string" <|
\( key, value ) ->
if List.map isNotEmptyTrimmedAlphabetWord [ key, value ] /= [ True, True ] then