-
-
Notifications
You must be signed in to change notification settings - Fork 603
Description
Bug description
I want to run a regex validation rule on an Assets field type so I can ensure that filenames match a desired pattern.
However, validation always fails on an Asset field type when using the regex or not_regex validation rules because the current logic runs preg_match on the array itself and does not check if the value is an array first (like several of the other validation rules do).
I figured this was a bug instead of a feature request because several other validation rules do array checking and work well with Asset arrays. So it makes sense that we could run regex rules on an array of file paths too.
How to reproduce
- Create an Asset field type
- Add a
regexornot_regexrule - Upload an asset and submit
- Validation always fails
Logs
{
"message": "The given data was invalid.",
"errors": {
"story_mp3": [
"Format is invalid."
]
}
}Versions
Statamic 3.3.16 Pro
Laravel 8.83.17
PHP 8.0.18
statamic/ssg 1.0.1
swiftmade/statamic-clear-assets 1.1.0
withcandour/aardvark-seo 2.0.27
Installation
Fresh statamic/statamic site via CLI
Antlers Parser
No response
Additional details
Statamic is the best!