Typed strings
In addition to the primitive String
type, Bosque provides two additional types to broaden the possibilities through extra features such as metadata or supporting validation through regular expressions – SafeString<T>
and StringOf<T>
. Let's learn more about these in the following subsections.
SafeString<T>
The SafeString
<T>
type is defined by a parameter representing a validation pattern for its content through a regular expression. This feature can be useful for simplifying string formatting or for performing content validation.
Let's consider an example program to convert USD to EUR that are provided as strings with the currency symbol.
Important note
As of this writing, the methods of the String
and Regex
entities presented in the next example are not fully implemented yet. Therefore the code will not compile properly. Keep this in mind while analyzing it.
Have a look at the following practical example:
...