Is Nesting Schemas Inside Each Other an Anti-Pattern?

Is it an anti-pattern to "nest" schemas inside on another?

export class Product extends Schema.TaggedClass<Product>("Product")("Product", {
  id: ProductId,
  title: Schema.String,
  description: Schema.NullOr(Schema.String),
  status: Schema.Literal("draft", "published"),
  options: Schema.Array(ProductOption),
}) {}


It is giving me a lot of trouble trying to create those entities later in my program.

return new Product({
            ...product,
            id: ProductId.make(product.id),
            options: product.options.map(
              (option) =>
                new ProductOption({
                  title: option.title,
                  id: ProductOptionId.make(option.id),
                  productId: ProductId.make(option.productId),
                }),
            ),
          });
Was this page helpful?