directus / directus/directus

Parts of field validations are not working as expected

Open
#18,955 4 comments 0 reactions 0 assignees View on GitHub
Bug Studio Validation
Dominant language
TypeScript
Stars
37.9k
Forks
4.9k
Avg merge
3d 21h
Merged PRs (30d)
36

Description

### Describe the Bug

Hello,

parts of field validations are not working as expected.

### To Reproduce

Example 1
1. Create a simple String Field 'A' in Directus Users.
2. Create Many to One Field 'B' in Directus Users, that has a relationship to Directus Users
3. In Field 'B' add a validation 'B -> A Isn't null'
4. Edit a User and write any value in Field A.
5. Edit an other User and add in Field B, the User that was edited before (that has a value in Field A)
Now an Error Message appears: {"errors":[{"message":"\"B\" must be of type object","extensions":{"code":"FAILED_VALIDATION","field":"B"}}]}

Example 2
1. Create Many to One Field 'C' in Directus Users, that has a relationship to Directus Users
2. Add to this Field a Validation: 'C Contains $CURRENT_USER'
3. Edit a User and add the Current User to Field C.
4. {"errors":[{"message":"\"C\" must contain [$CURRENT_USER]","extensions":{"code":"FAILED_VALIDATION","field":"C","type":"contains","substring":"$CURRENT_USER"}}]}

### Directus Version

v10.1.1 and v10.3.0

### Hosting Strategy

Self-Hosted (Docker Image)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.