You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, it looks like there might be an issue with validating nested lists.
Repro:
defmoduleNestedListStructdouseGuardedStructguardedstructdosub_field(:list,list(struct()),structs: true,derive: "validate(list, not_empty)",enforce: true)dofield(:id,String.t(),enforce: true)sub_field(:sublist,list(struct()),structs: true,derive: "validate(list, not_empty)",enforce: true)dofield(:id,String.t(),enforce: true)endendendendassert{:ok,list}=NestedListStruct.builder(%{"list"=>[%{"id"=>"1","sublist"=>[%{"id"=>"2"}]}]})# this error will be returned about missing required fields, but it's expected to work given struct definition{:error,[%{field: :list,errors: [%{field: :sublist,errors: %{message: "Please submit required fields.",fields: [:id],action: :required_fields}}]}]}
Also if sublist is renamed to list in both places struct and input, another issue occurs vs working as expected:
{:error, [%{field: :list, errors: [%{field: :list, errors: [%{message: "The list field must be list", field: :list, action: :list}]}]}]}
The text was updated successfully, but these errors were encountered:
Hi @svsool , Amm... ; I think it is kind a bug!! let me test it more. I hope it is not going to be hard part of macro !! without structs it works, but as a nested list ! no 😢
It seems the validation is working but sending data to inner module can not know about the map keys
First of all, thank you for the report you submitted.
Unfortunately, this part has a lot of dependencies. I spent the whole day working on it, but the changes affect other parts of the code as well.
For this reason, it is recommended to use derive and a custom function. Otherwise, unfortunately, you might need to use other libraries that support this feature.
I won’t be able to follow up on this issue for now.
I’d still be happy if someone manages to solve the problem and submits a pull request.
This issue only occurs when dealing with nested lists. The macro cannot determine which loop it is in, preventing it from executing the specific data of that loop for the next condition.
Hi, it looks like there might be an issue with validating nested lists.
Repro:
Also if
sublist
is renamed tolist
in both places struct and input, another issue occurs vs working as expected:{:error, [%{field: :list, errors: [%{field: :list, errors: [%{message: "The list field must be list", field: :list, action: :list}]}]}]}
The text was updated successfully, but these errors were encountered: