Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow date strings in gt(e)/lt(e)/between in validation step #8214

Closed
3 tasks done
rijkvanzanten opened this issue Sep 21, 2021 · 1 comment · Fixed by #8283
Closed
3 tasks done

Allow date strings in gt(e)/lt(e)/between in validation step #8214

rijkvanzanten opened this issue Sep 21, 2021 · 1 comment · Fixed by #8283
Assignees
Labels

Comments

@rijkvanzanten
Copy link
Member

Preflight Checklist

Describe the Bug

Currently, the generate joi function relies on Joi's number type to create the validation rules:

if (operator === '_lt') {
schema[key] = getNumberSchema().less(Number(compareValue));
}
if (operator === '_lte') {
schema[key] = getNumberSchema().max(Number(compareValue));
}

This fails when the value to compare against is a string (like 2021-09-21) with Error: limit must be a number or reference.

This is different from permissions, where the filter is applied as a query in SQL, which does accept this difference.

To Reproduce

Try using dates in validation with a gte/between etc type field, for example:

{
    "date": {
        "_between": [
            "2020-09-10",
            "2021-09-15"
        ]
    }
}

What version of Directus are you using?

v9.0.0-rc.93

What version of Node.js are you using?

16.4

What database are you using?

Postgres

What browser are you using?

Safari

What operating system are you using?

macOS

How are you deploying Directus?

Locally

@rijkvanzanten
Copy link
Member Author

We might be able to solve for this by checking if the value is a number first, and if it isn't default to a "date", as numbers and dates are the only two types you can use with greater than / between

@azrikahar azrikahar self-assigned this Sep 24, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants