Literal Layouts
You can use literals as types to specify that the only possible value is the string literal itself. For instance, the following type defines the property constant
whose value must be equal to "foo"
.
layout Foo {
constant: "foo"
}
Regular Expression Layouts
Literal layouts are a particular case for regular expression types, where each instance of the type matches the defining regular expression.
The following layout defines the regexp
property whose value must match the /foo+/
regular expression recognizing every "fo...o"
string with at least two o
.
layout Foo {
regexp: /foo+/
}
Last updated
Was this helpful?