notEmpty
Validates that a field is not empty.
Options
| Option | Type | Default | Description |
|---|---|---|---|
trim | boolean | false | If true, trims whitespace before checking — " " becomes invalid |
message | string | locale default | Custom error message |
Playground
Valid values
| Value | Notes |
|---|---|
"hello" | Non-empty string |
"0" | The string "0" is non-empty |
" hello " | Whitespace around content |
Invalid values
| Value | Reason |
|---|---|
"" | Empty string |
" " | Whitespace only (when trim: true) |
Notes
- Unlike all other validators,
notEmptyreturnsvalid: falsefor empty string. - Use with
trim: trueif you want to reject values that are only spaces.