mirror of
https://github.com/ash-project/ash_phoenix.git
synced 2024-09-20 07:12:49 +12:00
fix: support only predicate in params
This commit is contained in:
parent
032f7d6850
commit
4c4ca71609
2 changed files with 9 additions and 5 deletions
|
@ -87,18 +87,18 @@ defmodule AshPhoenix.FilterForm do
|
||||||
At present, no validation actually occurs, but this will eventually be added.
|
At present, no validation actually occurs, but this will eventually be added.
|
||||||
"""
|
"""
|
||||||
def validate(form, params \\ %{}) do
|
def validate(form, params \\ %{}) do
|
||||||
|
params = sanitize_params(params)
|
||||||
|
|
||||||
params =
|
params =
|
||||||
if is_predicate?(params) do
|
if is_predicate?(params) do
|
||||||
%{
|
%{
|
||||||
operator: :and,
|
"operator" => "and",
|
||||||
components: %{"0" => params}
|
"components" => %{"0" => params}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
params
|
params
|
||||||
end
|
end
|
||||||
|
|
||||||
params = sanitize_params(params)
|
|
||||||
|
|
||||||
%{
|
%{
|
||||||
form
|
form
|
||||||
| params: params,
|
| params: params,
|
||||||
|
|
|
@ -77,7 +77,11 @@ defmodule AshPhoenix.FilterFormTest do
|
||||||
describe "to_filter/1" do
|
describe "to_filter/1" do
|
||||||
test "An empty form returns the filter `true`" do
|
test "An empty form returns the filter `true`" do
|
||||||
form = FilterForm.new(Post)
|
form = FilterForm.new(Post)
|
||||||
assert Ash.Query.equivalent_to?(FilterForm.filter!(Post, form), true)
|
|
||||||
|
assert Ash.Query.equivalent_to?(
|
||||||
|
FilterForm.filter!(Post, form),
|
||||||
|
true
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "A form with a single predicate returns the corresponding filter" do
|
test "A form with a single predicate returns the corresponding filter" do
|
||||||
|
|
Loading…
Reference in a new issue