Suppose I wanted to create a Record type that represents acceptable min/max bounds:
type Bounds = { Min: float; Max: float }
Is there a way to enforce that Min < Max? It is easy to write a validateBounds function, I was just wondering if there was a better way to do this.
Edit: I realized that for this specific example I could probably get away with exposing two properties and re-order the arguments, so let's say we were trying to do
type Person = { Name: string }
and Name needs to have at least one character.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…