Advanced Guides

Error handling

Common validation errors and how to avoid them

Overview

Decorated Factory fails fast with clear errors when you:

  • Supply a negative amount to .with() or .many().make().
  • Call .set() for a nested path without its parent .with().
  • Try to generate an array of AutoIncrement values (unsupported by design).

Examples

// Examples
factory.one(User).with(-1, 'photos').make(); // throws
 
factory.one(User).set('photo.url', 'x'); // throws (no .with('photo'))
 
class T {
  @FactoryType(() => [AutoIncrement])
  ids: number[];
}
// building an array of AutoIncrement throws

Tips

Always .with() nested relations before overriding/excluding inside them, and use non-negative amounts when sizing arrays.

On this page