Effect CommunityEC
Effect Community2y ago
4 replies
Kroeber

Self-referential Struct Schema

Hi, is it possible for a Struct's property to be schema self-referential and simultaneously have it constrained by another of its properties? I'm trying to do something like this, but don't know if there's support for it:

const schema = S.Struct({
  min: S.Number,
  max: S.suspend(
    (): S.Schema<number> => S.Number.pipe(
      S.greaterThan(schema.fields.min)
    )
  ),
});
Was this page helpful?