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

[Question] Creating rules on vine "VineArray" #27

Open
shankiflang opened this issue Jan 29, 2024 · 6 comments
Open

[Question] Creating rules on vine "VineArray" #27

shankiflang opened this issue Jan 29, 2024 · 6 comments
Assignees
Labels
Status: Investigating We are investigating the issue to get more information Type: Question Needs clarification

Comments

@shankiflang
Copy link

shankiflang commented Jan 29, 2024

Package version

"@adonisjs/core": "^6.2.2",
"@vinejs/vine": "^1.7.0"

Describe the bug

Hey,
I have an array that I want to make conditional depending on whether or not an object is present in my database. On the doc it's explained for VineString, but I can't figure out how to do it with VineArray. Does anyone have any ideas?

@thetutlage
Copy link
Contributor

Its same for all the schema classes, be it VineString, VineObject, or VineArray.

@thetutlage thetutlage self-assigned this Jan 29, 2024
@thetutlage thetutlage added the Type: Question Needs clarification label Jan 29, 2024
@shankiflang
Copy link
Author

Its same for all the schema classes, be it VineString, VineObject, or VineArray.

Here's the problem I'm having with VineArray:
image

@shankiflang
Copy link
Author

@thetutlage I can't seem to add a custom rule to the Array type. When I copy the doc for the unique() rule, and remove the string checks, it isn't executed, but it is on a string() entry. None of my rules are executed on array(), is this normal?

@thetutlage
Copy link
Contributor

Hello, can you please share a reproduction repo with for the same and I will try to debug and see if I can provide some helpful info

@shankiflang
Copy link
Author

Hello, can you please share a reproduction repo with for the same and I will try to debug and see if I can provide some helpful info

You can find a repo here: https://github.com/shankiflang/repo-repro. As far as I can see, the implicit : true doesn't work.

If I set the data for a message to:

{
    "postId": 1
}

the isRequiredIfPostPublishedRule() method is not called. In contrast, if I put :

{
    "postId": 1,
    "config": [
        {
            "hi": "foo"
        }
    ]
}

The method is called.

@thetutlage thetutlage added the Status: Investigating We are investigating the issue to get more information label Jan 31, 2024
@thetutlage
Copy link
Contributor

Thanks for the repro. I will look into it once I get some time and see if rules on an array respect the implict flag or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Investigating We are investigating the issue to get more information Type: Question Needs clarification
Projects
None yet
Development

No branches or pull requests

2 participants