Introduction to Refined types in Scala
Refined is a library that combines
Newtype with validation, allowing developers to model validated domain values as types rather than using raw primitives (avoiding 'primitive obsession'). A refined value consists of the original value type (e.g., String, Int), a validation predicate, and a specific error message (invalidReason) used when validation fails. This approach enables catching invalid literals at compile-time and ensures runtime validation is explicit and total using Either.import refined4s.*