[英]Erlang json validation issue
I'm kinda new to erlang 我对Erlang有点陌生
trying to make JSON validation using https://github.com/Prots/olifer 尝试使用https://github.com/Prots/olifer进行JSON验证
but getting error: 但出现错误:
1> sql_app:update(<<"0.2851">>,<<"frfrfrfr">>). 1> sql_app:update(<<“ 0.2851” >>,<<“ frfrfrfr” >>)。
** exception error: no case clause matching [{<<"0.2851">>, <<"FORMAT_ERROR">>}] in function sql_app:update/2 (c:/sql/_build/default/lib/sql/src/sql_app.erl, line 31) **异常错误:函数sql_app:update / 2(c:/ sql / _build / default / lib / sql / src中没有匹配[{<<“ 0.2851” >>,<<“ FORMAT_ERROR” >>}}]的case子句/sql_app.erl,第31行)
the function is: 函数是:
update(Id, Info) ->
case olifer:validate(Id, [{<<"string">>, <<"required">>}]) of
{ok, _} ->
emysql:prepare(info, <<"UPDATE vobla SET info = ? WHERE id = ?">>),
Result1 = emysql:execute(erlang, info, [Info, Id]),
io:format("~n~p~n", [Result1]);
{errors, _} -> io:format("~n~p~n", [error])
end.
Could you please help me to figure it out. 您能帮我解决一下吗。
thanks in advance. 提前致谢。
It means that the case clause you have written does not match the result passed [{<<"0.2851">>, <<"FORMAT_ERROR">>}]
. 这意味着您编写的case子句与传递的结果[{<<"0.2851">>, <<"FORMAT_ERROR">>}]
不匹配。 Your case clauses matches tuples of the format {ok, _}
or {errors, _}
. 您的case子句匹配格式为{ok, _}
或{errors, _}
元组。 Not a list. 没有清单。
update(Id, Info) ->
Res = olifer:validate(Id, [{<<"string">>, <<"required">>}]),
io:format("~p", [Res]),
case Res of
[Tup] -> do_something; % could be an error
{ok, _} -> % validation success
emysql:prepare(info, <<"UPDATE vobla SET info = ? WHERE id = ?">>),
Result1 = emysql:execute(erlang, info, [Info, Id]),
io:format("~n~p~n", [Result1]);
{errors, _err} -> io:format("~n~p~n", [_err])
end.
You are having a format error as per the log. 根据日志,您遇到格式错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.