Skip to content

Asset container upload validation (validate: key) isn't documented #1964

Description

@JasperWelsing

Asset container upload validation (validate: key) isn't documented

Asset containers support a validate: key in their YAML config (e.g. content/assets/<container>.yaml) that caps/validates uploads made directly through the Assets Browser. This is the only way to restrict those uploads — blueprint field-level validate rules only apply when uploading through that specific field's picker on an entry form, not through Assets → [container] → Upload. I couldn't find this documented on statamic.dev, and it isn't mentioned in config/statamic/assets.php.

Example

# content/assets/assets.yaml
title: Media
disk: assets
allow_uploads: true
validate:
  - max:20480   # KB — rejects uploads over 20MB

Oversized uploads are rejected with a normal 422 validation error, rendered inline by the Assets Browser UI.

Source reference

- Statamic\Assets\AssetContainer::validationRules() — getter/setter, backed by fluentlyGetOrSet('validation').
- Statamic\Stache\Stores\AssetContainersStore::makeItemFromFile() — reads validate from YAML.
- Statamic\Assets\AssetContainer::fileData() — writes it back out as validate.
- Statamic\Http\Controllers\CP\Assets\AssetsController::store() — merges validationRules() into the file validation rules.

Load/save are consistent (both use validate), so this isn't a bug — just a naming mismatch between the YAML key and the PHP accessor (validationRules()), which makes the feature hard to discover.

Suggestion

Document the container-level validate: key on the Assets / Asset Containers page on statamic.dev.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions