knuckleswtf / knuckleswtf/scribe

Try It Now with Array Datas When Nullable

Open
#990 0 comments 0 reactions 0 assignees View on GitHub
bug triage
Dominant language
PHP
Stars
2.3k
Forks
357
PR merge metrics
No merged PRs in 30d

Description

### Scribe version

5.2.0

### PHP version

8.2

### Laravel version

12.10.2

### Scribe config

```ruby
laravel.middleware.0 => "web"
laravel.middleware.1 => "scribe.auth"
auth.enabled => true
auth.placeholder => "{BEARER_TOKEN}"
examples.faker_seed => null
```

### What happened?

I use the following FormRequest:

```php
public function rules(): array
{
return [
'instagram_user_id' => [
'nullable',
],
'instagram_user_id.*' => [
'int',
];
}
```

Users should be able to leave the instagram_user_id field empty. However, when I use the “Try it out” feature in Scribe, it doesn’t send an empty value—instead, it sends something like `instagram_user_id = [null, null]`. This causes a validation error because `instagram_user_id.*` expects integers, but gets `null` values instead.

Expected Behavior

When using the “Try it out” feature in Scribe, if the instagram_user_id field is left empty, the request should either:

- Not include the `instagram_user_id` key at all,
or
- Send it as an empty array: `instagram_user_id: []`

This way, the validation passes because:
- The field is nullable
- And there are no non-integer (e.g., null) values inside the array that would trigger the `instagram_user_id.* => int` rule

### Docs

- [x] I've checked [the docs](https://scribe.knuckles.wtf/laravel), the [troubleshooting guide](https://scribe.knuckles.wtf/laravel/troubleshooting), and [existing issues](https://github.com/knuckleswtf/scribe/issues?q=is%3Aissue+), but I didn't find a solution

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue in Scribe's Laravel “Try it out” feature using the shown FormRequest and nullable array field. Inspect the generated request payload, then verify that an empty field is omitted or sent as an empty array and that Laravel validation no longer receives null array elements.

Written by the indexing model from the issue text.

Assessment

Tech stack
laravel, php
Domain
api, documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.