10.4 String types

The line field type specifier can be used to restrict the value
of a field to a single line, i.e. no newline characters are allowed.
For example, a type for proper names could be declared as:

%typedef: Name_t line

Examples of fields of type line:

Name: Mr. Foo Bar
Name: Mss. Bar Baz
Name: This is
+ invalid

Sometimes it is the maximum size of the field value that shall be
restricted. The size field type specifier can be used to
define the maximum number of characters a field value can have. For
example, if we were collecting input that will get written in a
paper-based forms system allowing up to 25 characters width entries,
we could declare the entries as:

%typedef: Address_t size 25

Note that hexadecimal and octal integer constants can also be used to
specify field sizes:

%typedef: Address_t size 0x18

Arbitrary restrictions can be defined by using regular expressions.
The regexp field type specifier introduces an ERE (extended
regular expression) that will be matched against fields having that
name. The synopsis is:

%typedef: type_name regexp /re/

For example, consider the Id_t type designed to represent
the encoding of the identifier of ID cards in some country:

%typedef: Id_t regexp /[0-9]{9}[a-zA-Z]/

Examples of fields of type Id_t are:

IDCard: 123456789Z
IDCard: invalid id card

Note that the slashes delimiting the RE can be replaced with
any other character that is not itself used as part of the regexp.
That is useful in some cases such as:

%typedef: Path_t regexp |(/[^/]/?)+|

The regexp flavor supported in recfiles are the POSIX EREs plus
several GNU extensions. See Regular Expressions.