Skip to content

Conversation

@markusheinemann
Copy link

@markusheinemann markusheinemann commented Oct 22, 2025

This PR is a proposal to resolve #57437.

With this change, users can specify a wildcard to trigger all validation rules for an array field when using precognitive requests. Before the change the user had to specify all array validation rules manually in the Precognition-Validate-Only header. Now wildcards can specified to cover all array entries.

// Before
Precognition-Validate-Only: nested_array,nested_array.0.title,nested_array.1.title,nested_array.2.title
Precognition-Validate-Only: raw_array,raw_array.0,raw_array.1,raw_array.2

// After
Precognition-Validate-Only: nested_array,nested_array.*.title
Precognition-Validate-Only: raw_array,raw_array.*

PS. This is my first PR for Laravel so please forgive me mistakes. I appreciate any feedback :)

@timacdonald
Copy link
Member

@markusheinemann, what do you think about making this a little less strict and allow a * to match anything that isn't a .?

Just thinking it could be cool to do users.* and it match users.name and users.email.

Then you could do something like users.*.* to match users.1.name and users.1.email, etc.

@markusheinemann
Copy link
Author

markusheinemann commented Nov 6, 2025

@timacdonald Totally agree. Would be a nice convenience feature...

Would we assume that user.* is the same as users.*.* but not as users.*.email? Or should we force that the wildcard only work at on level (e.g. to match users.names.first the wildcard users.*.* needs to be specified). I think the second way is more explicit.

I take a look into a adjusted implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CanBePrecognitive Trait dose not consider Validation Rules for Arrays

2 participants