chore(message transformation): allow empty operation list
Fixes https://emqx.atlassian.net/browse/EMQX-12682
This commit is contained in:
parent
01d89be743
commit
5f595966d8
|
@ -108,8 +108,7 @@ fields(transformation) ->
|
||||||
hoconsc:array(ref(operation)),
|
hoconsc:array(ref(operation)),
|
||||||
#{
|
#{
|
||||||
desc => ?DESC("operation"),
|
desc => ?DESC("operation"),
|
||||||
required => true,
|
default => []
|
||||||
validator => fun validate_operations/1
|
|
||||||
}
|
}
|
||||||
)}
|
)}
|
||||||
];
|
];
|
||||||
|
@ -253,11 +252,6 @@ validate_unique_topics(Topics) ->
|
||||||
{error, Msg}
|
{error, Msg}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
validate_operations([]) ->
|
|
||||||
{error, <<"at least one operation must be defined">>};
|
|
||||||
validate_operations([_ | _]) ->
|
|
||||||
ok.
|
|
||||||
|
|
||||||
compile_variform(Expression, #{make_serializable := true}) ->
|
compile_variform(Expression, #{make_serializable := true}) ->
|
||||||
case is_binary(Expression) of
|
case is_binary(Expression) of
|
||||||
true ->
|
true ->
|
||||||
|
|
|
@ -114,14 +114,9 @@ schema_test_() ->
|
||||||
transformation(<<"foo">>, [dummy_operation()])
|
transformation(<<"foo">>, [dummy_operation()])
|
||||||
])
|
])
|
||||||
)},
|
)},
|
||||||
{"operations must be non-empty",
|
{"operations may be empty",
|
||||||
?_assertThrow(
|
?_assertMatch(
|
||||||
{_Schema, [
|
[#{<<"operations">> := []}],
|
||||||
#{
|
|
||||||
reason := <<"at least one operation must be defined">>,
|
|
||||||
kind := validation_error
|
|
||||||
}
|
|
||||||
]},
|
|
||||||
parse_and_check([
|
parse_and_check([
|
||||||
transformation(
|
transformation(
|
||||||
<<"foo">>,
|
<<"foo">>,
|
||||||
|
|
Loading…
Reference in New Issue