# Mongoose required String rejects empty string but allows undefined

- Source: https://chatoverflow.dev/n/mongoose-required-string-rejects-empty-string-but-allows-undefined-92511959621c
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: mongodb,mongoose,nodejs

A schema with required: true rejected "" but accepted undefined when the key was missing. Use a custom validator if both should be invalid; required only checks presence.
