<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="242800" data-post-id="242800">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="jonericcook" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jonericcook/120/19167_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  jonericcook
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>when i remove <code>, multi: true</code> it makes it happy <img src="https://forum.elixirforum.com/images/emoji/apple/confused.png?v=15" title=":confused:" class="emoji" alt=":confused:" loading="lazy" width="20" height="20"></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="242800" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/xema-and-jsonxema-schema-validatiors/20069/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-242800" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="242800"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #11"></div>
  </section>
</div>
    <div class="postbit" id="242805" data-post-id="242805">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Marcus" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Marcus/120/24640_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Marcus
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I am happy that you like <code>Xema</code>. I will take a look to the dialyzer issue. Thanks for reporting. If you like you can crate an issue on GitHub.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="242805" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/xema-and-jsonxema-schema-validatiors/20069/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-242805" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="242805"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #12"></div>
  </section>
</div>
    <div class="postbit" id="242809" data-post-id="242809">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Marcus" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Marcus/120/24640_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Marcus
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I have made some fixes. The attribute <code>@default true</code> to mark a schema as default is now deprecated. That is not a part of your example but a part of the problem. Now a default schema is marked with the <code>:default</code> option.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmoudle MyApp.Schemas do
  use Xemae, multi: true, default: :s1

  xema :s1 do
    ...
  end

  xema :s2 do
    ...
  end
end
</code></pre>
<p>I still have to adjust some things before I release a new version. If you like you can test the fix/refactoring with the GitHub main brach: <code>{:xema, git: "https://github.com/hrzndhrn/xema"}</code>.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="242809" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/xema-and-jsonxema-schema-validatiors/20069/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-242809" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="242809"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #13"></div>
  </section>
</div>
    <div class="postbit" id="252316" data-post-id="252316">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="egze" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/egze/120/13522_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  egze
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p><a class="mention" href="/u/marcus" rel="nofollow">@Marcus</a> your library is <img src="https://forum.elixirforum.com/images/emoji/apple/fire.png?v=15" title=":fire:" class="emoji" alt=":fire:" loading="lazy" width="20" height="20"></p>
<p>I’m wondering, how would you build a form in Phoenix for schemas that are not known ahead of time? I’m thinking something flexible like <a href="https://github.com/json-editor/json-editor" rel="noopener nofollow ugc">json-editor</a></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="252316" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/xema-and-jsonxema-schema-validatiors/20069/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-252316" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="252316"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #14"></div>
  </section>
</div>
    <div class="postbit" id="252596" data-post-id="252596">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Marcus" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Marcus/120/24640_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Marcus
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Hello <a class="mention" href="/u/egze" rel="nofollow">@egze</a> thanks for the <img src="https://forum.elixirforum.com/images/emoji/apple/fire.png?v=15" title=":fire:" class="emoji" alt=":fire:" loading="lazy" width="20" height="20"> and sorry for the late response.</p>
<p>The JSON-Editor could be a good example to show how <code>xema</code> works together with phoenix-forms.</p>
<p>At the moment I have no idea for the form but a simplified first approach for the schema could be:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule Form do
  use Xema

  @str map(properties: %{t: [const: "str"], v: :string})
  @int map(properties: %{t: [const: "int"], v: :integer})
  @obj map(
         properties: %{
           t: [const: "obj"],
           v:
             map(
               property_names: string(min_length: 1),
               pattern_properties: %{".*" =&gt; ref("#")}
             )
         }
       )
  @arr list(items: ref("#"))

  xema do
    one_of([@str, @int, @arr, @obj])
  end
end
</code></pre>
<p>That would work for:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">iex&gt; Form.valid?(%{t: "str", v: "Hinz"})
true
iex&gt; Form.valid?(%{
  t: "obj",
  v: %{
    foo: %{t: "int", v: 55},
    bar: [%{t: "str", v: "Hinz"}, %{t: "str", v: "Kunz"}]
  }
})
</code></pre>
<p>In case of invalid data the error reason is a little bit hard to handle.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">iex&gt; Form.validate(%{
  t: "obj",
  v: %{
    foo: %{t: "int", v: 55},
    bar: [%{t: "str", v: "Hinz"}, %{t: "str", v: 88}]
  }
})
{:error,
 %Xema.ValidationError{
   message: nil,
   reason: %{
     one_of: {:error,
      [
        %{
          properties: %{
            t: %{const: "str", value: "obj"},
            v: %{
              type: :string,
              value: %{bar: [%{t: "str", v: "Hinz"}, %{t: "str", v: 88}], foo: %{t: "int", v: 55}}
            }
          }
        },
        %{
          properties: %{
            t: %{const: "int", value: "obj"},
            v: %{
              type: :integer,
              value: %{bar: [%{t: "str", v: "Hinz"}, %{t: "str", v: 88}], foo: %{t: "int", v: 55}}
            }
          }
        },
        %{
          type: :list,
          value: %{
            t: "obj",
            v: %{bar: [%{t: "str", v: "Hinz"}, %{t: "str", v: 88}], foo: %{t: "int", v: 55}}
          }
        },
        %{
          properties: %{
            v: %{
              properties: %{
                bar: %{
                  one_of: {:error,
                   [
                     %{type: :map, value: [%{t: "str", v: "Hinz"}, %{t: "str", v: 88}]},
                     %{type: :map, value: [%{t: "str", v: "Hinz"}, %{t: "str", v: 88}]},
                     %{
                       items: %{
                         1 =&gt; %{
                           one_of: {:error,
                            [
                              %{properties: %{v: %{type: :string, value: 88}}},
                              %{properties: %{t: %{const: "int", value: "str"}}},
                              %{type: :list, value: %{t: "str", v: 88}},
                              %{
                                properties: %{
                                  t: %{const: "obj", value: "str"},
                                  v: %{type: :map, value: 88}
                                }
                              }
                            ]},
                           value: %{t: "str", v: 88}
                         }
                       }
                     },
                     %{type: :map, value: [%{t: "str", v: "Hinz"}, %{t: "str", v: 88}]}
                   ]},
                  value: [%{t: "str", v: "Hinz"}, %{t: "str", v: 88}]
                }
              }
            }
          }
        }
      ]},
     value: %{
       t: "obj",
       v: %{bar: [%{t: "str", v: "Hinz"}, %{t: "str", v: 88}], foo: %{t: "int", v: 55}}
     }
   }
 }}

</code></pre>
<p>I think this could be improved in <code>xema</code>.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="252596" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/xema-and-jsonxema-schema-validatiors/20069/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-252596" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="252596"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>