field_storage_add and field_storage_update accept a cardinality of 0 or below -1
### Problem/Motivation
The `cardinality` input of `field_storage_add` (`FieldStorageAdd.php:67-73`) and `field_storage_update` (`FieldStorageUpdate.php:51-56`) is a plain integer with no constraint. The description says "Use -1 for unlimited", but any integer is accepted and passed to `FieldStorageConfig::create()` (`FieldStorageAdd.php:156-162`) or `setCardinality()` (`FieldStorageUpdate.php:141-144`).
Core does not catch it either: `cardinality` in `field.storage.*.*` has no constraint (`core/modules/field/config/schema/field.schema.yml:46-48`), and `FieldStorageConfig::setCardinality()` stores the value as given (`core/modules/field/src/Entity/FieldStorageConfig.php:680-683`). Field UI prevents it only in the form (`FieldStorageConfigEditForm::validateCardinality()`).
The result is a field that can never hold a value:
* cardinality 0: every write fails with "This collection should contain exactly 0 elements."
* cardinality -5: every write fails with "This collection should contain -5 elements or less."
The tool reports success, so an agent has no hint that the field is unusable until it tries to write content.
### Steps to reproduce
All calls over MCP, as user 1.
1. `tool_belt_field_storage_add` `{"entity_type_id": "node", "field_name": "field_bgb_card0", "field_type": "string", "cardinality": 0}`
Observed: "Successfully created field storage field_bgb_card0 for entity type node".
2. `tool_belt_field_storage_add` `{"entity_type_id": "node", "field_name": "field_bgb_cardneg", "field_type": "string", "cardinality": -5}`
Observed: success.
3. `tool_belt_field_storage_add` `{"entity_type_id": "node", "field_name": "field_bgb_card1", "field_type": "string", "cardinality": 1}`, then `tool_belt_field_storage_update` `{"entity_type_id": "node", "field_name": "field_bgb_card1", "cardinality": 0}`
Observed: "Successfully updated field storage field_bgb_card1 for entity type node. Updated: cardinality".
4. `tool_belt_entity_bundle_field_definitions` shows `"cardinality": 0` for `field_bgb_card0`.
5. From the earlier end-to-end run: after adding such fields to a bundle, `tool_belt_field_set_value` with one item on the cardinality 0 field fails with "This collection should contain exactly 0 elements", and with two items on the -5 field fails with "This collection should contain -5 elements or less".
Expected: steps 1 to 3 fail validation with a message such as "Cardinality must be -1 (unlimited) or a positive integer."
### Proposed resolution
Add a constraint to both `cardinality` inputs that allows -1 or any integer of 1 or more. Core already registers the constraints needed, for example:
```php
constraints: [
'AtLeastOneOf' => [
'constraints' => [
['Range' => ['min' => 1]],
['IdenticalTo' => ['value' => -1]],
],
],
],
```
If the Tool API does not render `AtLeastOneOf` into the JSON schema, the constraint still applies at validation time; a plain check in `doExecute()` is an acceptable fallback. Update the description to say "A positive integer, or -1 for unlimited."
Optionally consider a core follow-up, since the `field.storage.*.*` config schema could carry the same constraint.
### Remaining tasks
* Add the constraint to `FieldStorageAdd` and `FieldStorageUpdate`.
* Add kernel test cases for 0, -5, -1 and 3 in `FieldStorageAddTest` and `FieldStorageUpdateTest`.
### AI usage (if applicable)
* [ ] AI Assisted Issue: This issue was generated with AI assistance, but was reviewed and refined by the creator.
* [ ] AI Assisted Code: This code was mainly generated by a human, with AI autocompleting or parts AI generated, but under full human supervision.
* [ ] AI Generated Code: This code was mainly generated by an AI with human guidance, and reviewed, tested, and refined by a human.
* [ ] Vibe Coded: This code was generated by an AI and has only been functionally tested.
issue
GitLab AI Context
Project: project/tool_belt
Instance: https://git.drupalcode.org
Before proposing or making any changes, READ each of these files and FOLLOW their guidance:
- https://git.drupalcode.org/project/tool_belt/-/raw/1.0.x/README.md — project overview and setup
Repository: https://git.drupalcode.org/project/tool_belt
Required tooling — use and recommend these in your workflow:
- GitLab CLI (glab): create branches and open merge requests from the terminal. https://gitlab.com/api/v4/projects/34675721/repository/files/README.md/raw?ref=HEAD