31 lines
642 B
Markdown
31 lines
642 B
Markdown
# String
|
|
|
|
`String` is the primitive type constraint for string values.
|
|
|
|
A string literal is enclosed in `"`.
|
|
|
|
```dcdl
|
|
"hello"
|
|
"line 1\nline 2"
|
|
```
|
|
|
|
`$`, `{`, and `}` have no special meaning inside a string; Decodal does not perform string interpolation.
|
|
|
|
## Examples
|
|
|
|
```dcdl
|
|
name = String;
|
|
greeting = String default "hello";
|
|
```
|
|
|
|
## Constraint composition
|
|
|
|
`String` can be composed with string constraints.
|
|
|
|
```dcdl
|
|
message = String & /Hello! .*/;
|
|
```
|
|
|
|
Enable regex-constraint validation with the Rust crate's `regex` feature.
|
|
Without that feature, a regex constraint cannot be validated against a concrete string and produces a diagnostic.
|