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
Currently the system-filter wraps all values in quotes: {"_and":[{"_and":[{"id":{"_eq":"5"}}]},{"status":{"_neq":"archived"}}]}
This causes the Joi validation in validatePayload() to fail on these numbers as they are submitted as strings.
A possible solution is to have system-filter use the field type to determine if it should wrap the value in quotes.
To Reproduce
Go to a collection page and enter a filter that contains a number.
See that the filter sends the number wrapped in quotes.
I wrote an automated test to see if validatePayload() could handle the wrong typings:
it('returns an error when the expected field type is a number and it is passed a string',()=>{constmockFilter={_and: [{field: {_eq: '1'}}]}asFilter;constmockPayload={field: 1};expect(validatePayload(mockFilter,mockPayload)).toHaveLength(1);expect(validatePayload(mockFilter,mockPayload)[0]).toBeInstanceOf(Joi.ValidationError);expect(validatePayload(mockFilter,mockPayload)[0]?.message).toBe('"field" must be [1]');});
The error is logged.
Errors Shown
From Jest test: [ValidationError: "field" must be [1]]
Describe the Bug
Currently the system-filter wraps all values in quotes:
{"_and":[{"_and":[{"id":{"_eq":"5"}}]},{"status":{"_neq":"archived"}}]}
This causes the Joi validation in
validatePayload()
to fail on these numbers as they are submitted as strings.A possible solution is to have
system-filter
use the field type to determine if it should wrap the value in quotes.To Reproduce
I wrote an automated test to see if validatePayload() could handle the wrong typings:
The error is logged.
Errors Shown
From Jest test: [ValidationError: "field" must be [1]]
What version of Directus are you using?
Latest
What version of Node.js are you using?
16.15.0
What database are you using?
Postgres
What browser are you using?
Brave
How are you deploying Directus?
Running locally
The text was updated successfully, but these errors were encountered: