Effect CommunityEC
Effect Community2y ago
7 replies
whatplan

Refining a Schema with Score Transformation in TypeScript

export const Score = S.Union(
  S.Literal(1),
  S.Literal(2),
  S.Literal(3),
  S.Literal(4),
  S.Literal(5),
);
export const ScoreFromNumber = S.transform(S.Number, Score, {
  encode: identity,
  decode: identity,
  strict: false,
});


is there a better way than this to do a refinement based of an existing schema?
Was this page helpful?