Skip to content

notEmpty

Validates that a field is not empty.

Options

OptionTypeDefaultDescription
trimbooleanfalseIf true, trims whitespace before checking — " " becomes invalid
messagestringlocale defaultCustom error message

Playground

Valid values

ValueNotes
"hello"Non-empty string
"0"The string "0" is non-empty
" hello "Whitespace around content

Invalid values

ValueReason
""Empty string
" "Whitespace only (when trim: true)

Notes

  • Unlike all other validators, notEmpty returns valid: false for empty string.
  • Use with trim: true if you want to reject values that are only spaces.

Released under the MIT License.