file
Validates file input constraints: allowed extensions, file size, and number of files.
Options
| Option | Type | Default | Description |
|---|---|---|---|
extension | string | undefined | Comma-separated allowed extensions without dots (e.g. "pdf,jpg,png") |
maxSize | number | undefined | Maximum file size in bytes |
minFiles | number | undefined | Minimum number of files |
maxFiles | number | undefined | Maximum number of files |
message | string | locale default | Custom error message |
Playground
Valid values
| Value | Notes |
|---|---|
.jpg file under 5 MB | Extension and size within limits |
.jpeg file | Matches allowed extensions |
Invalid values
| Value | Reason |
|---|---|
.exe file | Extension not in allowed list |
10 MB .jpg | Exceeds maxSize |
Notes
- Empty string (
"") always returnsvalid: true— validators only run on non-empty values. Combine withnotEmptyto require a value. extensionis comma-separated without dots:"pdf,jpg,png".maxSizeis in bytes:5 * 1024 * 1024for 5 MB.