Refinement types for Scala
Perhaps refined would help you? It lets you set constraints (i.e. "rules") for values / types. You get compile-time enforcement for constants and fallible methods for runtime values (i.e. Either[Error, RefinedValue]).
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.
Help with Single Value Validated Types
2 projects | reddit.com/r/scala | 27 Aug 2021
Types versus sets in math and programming languages
1 project | reddit.com/r/ProgrammingLanguages | 24 Jul 2021
Option as type of field in case class
1 project | reddit.com/r/scala | 28 Apr 2021
Using refined to improve type safety and error reporting in Scala
1 project | reddit.com/r/scala | 12 Apr 2021
Why there is still no ExpressJS-like alternative in Scala?
5 projects | reddit.com/r/scala | 7 Jan 2021