mirror of
https://github.com/ash-project/ash_phoenix.git
synced 2024-09-19 23:02:48 +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.
|
||||
"""
|
||||
def validate(form, params \\ %{}) do
|
||||
params = sanitize_params(params)
|
||||
|
||||
params =
|
||||
if is_predicate?(params) do
|
||||
%{
|
||||
operator: :and,
|
||||
components: %{"0" => params}
|
||||
"operator" => "and",
|
||||
"components" => %{"0" => params}
|
||||
}
|
||||
else
|
||||
params
|
||||
end
|
||||
|
||||
params = sanitize_params(params)
|
||||
|
||||
%{
|
||||
form
|
||||
| params: params,
|
||||
|
|
|
@ -77,7 +77,11 @@ defmodule AshPhoenix.FilterFormTest do
|
|||
describe "to_filter/1" do
|
||||
test "An empty form returns the filter `true`" do
|
||||
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
|
||||
|
||||
test "A form with a single predicate returns the corresponding filter" do
|
||||
|
|
Loading…
Reference in a new issue