FluentValidation · Common pitfalls
1 min readRapid 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
MustAsyncinstead. - 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
PropertyNamewhen usingRuleFor(x => x)root validators — map errors to clear property paths.