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

_regex filter matching empty string fails in joiValidationErrorItemToErrorExtensions #22394

Open
hanneskuettner opened this issue May 6, 2024 · 0 comments

Comments

@hanneskuettner
Copy link
Contributor

Describe the Bug

When using a _regex filter that is valid in case of an empty string ^$, the conversion from Joi to Directus error fails, as strings are not allowed to be empty in Joi by default1, which generates the error type 'string.empty' which is not accounted for in the conversion. We would have to explicitly allow empty strings in the default string schema in case of matching a regex, e.g. .allow('').

I'd like to discuss if it makes sense to allow matching empty strings in the _regexp filter or if this can result in breaking changes.

To Reproduce

  • Create a string field with Save as empty string
  • Set validation to Matches RegExp with the RegExp ^$|foo
  • Create a new item with value foo and save the value
  • Edit the item, remove the value and save
  • See error message

Directus Version

v10.10.7

Hosting Strategy

Self-Hosted (Docker Image)

Footnotes

  1. https://github.com/hapijs/joi/blob/master/API.md#string

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🆕 Needs Triage
Development

No branches or pull requests

1 participant