FluentValidation · Common pitfalls

1 min read
Mid-level6 min read
Rapid overview

Common pitfalls

  • Do not put persistence or side effects inside validators (e.g., saving logs, sending events).
  • Avoid long synchronous I/O (DB or HTTP) that will block the threadpool; use MustAsync instead.
  • Don't capture scoped services in singletons when injecting services into validators — prefer constructor-injected scoped/transient services and register validators with correct lifetimes.
  • Watch for ambiguous PropertyName when using RuleFor(x => x) root validators — map errors to clear property paths.

See also