-
Notifications
You must be signed in to change notification settings - Fork 49
failed to validate array with different types of complex objects #31
Comments
Or maybe more readable: (msg_accountmanagement@localhost)2> jesse:validate(<<"vnd.1and1.mams.user-agenda-modify-v1+json">>, <<"{\"add\": { \"contacts\": [{\"phone\": \"+23945827342\"}]}}">>, [{parser_fun, fun mochijson2:decode/1},{allowed_errors, 5}]).
{error,[{data_invalid,{struct,[{<<"type">>,
[{struct,[{<<"type">>,<<"object">>},
{<<"properties">>,
{struct,[{<<"phone">>,
{struct,[{<<"type">>,<<"string">>},
{<<"pattern">>,<<"^\\+\\"...>>},
{<<"requ"...>>,true}]}}]}},
{<<"additionalProperties">>,false}]},
{struct,[{<<"type">>,<<"object">>},
{<<"properties">>,
{struct,[{<<"email">>,
{struct,[{<<"type">>,<<"stri"...>>},
{<<"patt"...>>,<<...>>},
{<<...>>,...}]}}]}},
{<<"additionalProperties">>,false}]}]}]},
wrong_type,
{struct,[{<<"phone">>,<<"+23945827342">>}]},
[<<"add">>,<<"contacts">>,0]}]}
(msg_accountmanagement@localhost)3> |
Further investigation has shown that {data_invalid,
{struct,
[{<<"type">>,
[{struct,
[{<<"type">>,<<"object">>},
{<<"properties">>,
{struct,
[{<<"phone">>,
{struct,
[{<<"type">>,<<"string">>},
{<<"pattern">>,<<"^\\+\\d{10,15}$">>},
{<<"required">>,true}]}}]}},
{<<"additionalProperties">>,false}]},
{struct,
[{<<"type">>,<<"object">>},
{<<"properties">>,
{struct,
[{<<"email">>,
{struct,
[{<<"type">>,<<"string">>},
{<<"pattern">>,<<"^\\S+@\\S+\\.\\S+$">>},
{<<"required">>,true}]}}]}},
{<<"additionalProperties">>,false}]}]}]},
no_extra_properties_allowed,
{struct,[{<<"phone">>,<<"+23945827342">>}]},
[<<"add">>,<<"contacts">>,0,<<"phone">>]} when checking for type: {struct,[{<<"type">>,<<"object">>},
{<<"properties">>,
{struct,[{<<"phone">>,
{struct,[{<<"type">>,<<"string">>},
{<<"pattern">>,<<"^\\+\\d{10,15}$">>},
{<<"required">>,true}]}}]}},
{<<"additionalProperties">>,false}]} I'm puzzled about this 'no_extra_properties_allowed'... |
well, works for me, I get {ok, ...} btw, when I copied the schema from the first comment from you, jiffy could parse that complaining on the regexp strings, it seems it had some invisible unicode crap, so then I copied regexps from another comment, and it worked well. just to double check, what erlang version do you use? I'll test it on the same (currently I have R16B03 from default Ubuntu distribution) |
Hey, please check out my new pull request. I'm using Erlang/OTP 17.3 ... but having a hard time believing it could be the version used. |
And yeah, sorry, I don't know what's wrong with the regexp patterns here. If you go on "edit" for the first comment here it all looks nice but open safe it makes this weird thing. When saving it as a gist it works fine though: https://gist.github.com/sstrigler/aed786948d4f6f3d5ee1 |
Fix validation for array with set of types (refs #31)
fixed in 1.1.4 |
As requested this is a follow up on #30.
When using this schema as
vnd.1and1.mams.user-agenda-modify-v1+json
:calling jesse:validate on
results in the following (unexpected) error
The text was updated successfully, but these errors were encountered: