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
Just as suggestion or maybe I missing something and this can be already achieved:
defmoduleSomeIdentityParamsdouseParams.SchemaimportApp.Params.Helpers@fields~w(id code)schemadofield:id,:idfield:code,:string# more hereenddefchangeset(changeset,params)docast(changeset,params,@fields)|>at_least_one_should_be_present([:id,:code])endend# this one looks finedefmoduleSomeControllerParamsdouseParams.Schema@fields~w(tarif_id some_identity)aschemadofield:tarif_id,:idembeds_one:some_identity,SomeIdentityParamsenddefchangeset(cs,params)docast(cs,params,@fields)|>validate_required(@fields)|>cast_embed(:passenger,required: true)endend# but it can be much shorterdefmoduleSomeControllerParamsdouseParams.Schema,%{tarif_id: :id,some_identity: SomeIdentityParams}end
The text was updated successfully, but these errors were encountered:
Hey, using SomeIdentityParams directly would be nice, could you provide a PR? The only thing would be to check if the symbol resembles a module (ie its capitalized) then use embeds_one for it.
So if you were to assign SomeIdentityParams to :some_identity, how would params know it's a schema and not a type? If this was evaluated at runtime, it would be easy: call Kernel.function_exported?(SomeIdentityParams, :__schema__, 1) to discover that SomeIdentityParams is a schema. But it's not evaluated at runtime. It's evaluated at compile time. SomeIdentityParams is not loaded at compile time, and therefore the __schema__/1 function will not be exported.
Just as suggestion or maybe I missing something and this can be already achieved:
The text was updated successfully, but these errors were encountered: