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

Custom field validation not being triggered #16319

Open
tonyellow opened this issue Nov 4, 2022 · 6 comments
Open

Custom field validation not being triggered #16319

tonyellow opened this issue Nov 4, 2022 · 6 comments
Labels

Comments

@tonyellow
Copy link

Describe the Bug

I have a collection with a simple text field. I added a custom validation by editing the text field. It's a simple validation which just checks if the field is empty.

Screenshot 2022-11-04 at 08 57 24

When I add a new item to the collection and leave the text box empty, no validation error is shown.

To Reproduce

see bug

Errors Shown

none

What version of Directus are you using?

9.20.4

What version of Node.js are you using?

v16.18.0

What database are you using?

postgres 15

What browser are you using?

chrome osx

How are you deploying Directus?

local

@azrikahar
Copy link
Contributor

Duplicate of #15899, and it is currently tracked in #14571. Technically custom field validation does work when it is being sent. For example when we set validation as "Description contains abc", it will trigger when we set Description as any string without "abc". However it will not trigger when we do not edit Description, so it was never "sent", which is the crux of #14571 👍

@azrikahar azrikahar closed this as not planned Won't fix, can't repro, duplicate, stale Nov 4, 2022
@azrikahar
Copy link
Contributor

After looking into #14571, although validatePayload itself is also causing this field validation to not trigger when a field is not submitted, the fix for #14571 is currently isolated to Flows conditions operation as changes to validatePayload has a larger surface of impact.

Re-opening this to ensure this is still tracked 👍

@bhagyesh-7span
Copy link

bhagyesh-7span commented Dec 14, 2022

I tried to reproduce it and i came to know the following

  • Configured the collection as mentioned

image

  • Try to add the object with empty description

image

  • It created successfully

image

  • Then i tried added the data to the description field and it shows the validation mentioned

image

  • So if you want to validate the text if it is not empty you need to add the validation as

image

  • then i tried to add the item again with description empty and this happened

image

  • I checked the code and saw that in payload when you don't pass the description that field it is not validated by the JOI

image
image

  • If you want to validate you need to mark description field as required field then it will show you the validation message.
    image
    image

  • It can be still done if the fields with custom validation are passed in the request payload even if they are empty.

@rijkvanzanten
Copy link
Member

Linear: ENG-144

@bhagyesh-7span
Copy link

Is this issue now internal team issue ? or is it still available for us to debug @rijkvanzanten ?
I tried joining the linear but it shows i don't have access to the workspace ?

@br41nslug
Copy link
Member

@bhagyesh-7span You're still free to debug this issue if you want 😄 We've just linked the open issues to our internal issue tracker for better internal planning/tracking

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: 📋 Backlog
Development

No branches or pull requests

5 participants