Chars
The chars constraint restricts which characters may appear in a text value.
When negated using not_chars, it instead specifies forbidden characters.
This constraint applies only to text nodes and evaluates every character in the value individually.
Type Matrix
The following table summarizes the applicability of the chars constraint.
Node Type |
S |
Value Type |
Details |
|---|---|---|---|
Integer |
|||
Boolean |
|||
Float |
|||
Text |
Text
ValueList[Text]
|
Restricts the set of allowed characters ( |
|
Date |
|||
Time |
|||
DateTime |
|||
Bytes |
|||
TimeDelta |
|||
RegEx |
|||
Value |
|||
ValueList |
|||
ValueMatrix |
|||
Section |
|||
SectionList |
|||
SectionWithTexts |
|||
NotValidated |
Rules for Chars
Basic Semantics: The
charsconstraint defines a set of allowed characters.Validation succeeds only if every character in the text belongs to the union of all specified character sets.
[server.name] type: "text" chars: "(a-z)", "[%]", "digits"
Multiple Definitions (Union): Multiple values are combined using OR semantics.
A character is valid if it matches any of the specified ranges, lists, or named sets.
Supported Forms: Each value assigned to
charsmay be one of the following forms:Character range — enclosed in round brackets, e.g.
(a-z)Character list — enclosed in square brackets, e.g.
[%*,.]Named range — a predefined keyword, e.g.
digits
[server.name] type: "text" chars: * "(a-z)" # Character range * "[%*,.]" # Character list * "digits" # Named range
Character Ranges: Character ranges are defined as
(start-end)where start and end are single Unicode code points.start must have a lower code point than end
The expression must contain exactly five code points
Combining characters are not allowed
[server.name] type: "text" chars: "(a-z)" # Allows lowercase ASCII letters
Character Lists: Character lists are defined as
[characters].Each listed character must be unique
The outer square brackets are structural; inner characters are literal
No escaping is required inside the list
[server.name] type: "text" chars: "[0123456789abcdefABCDEF]" # Hexadecimal digits
Named Ranges: Values not enclosed in brackets are interpreted as named ranges.
The following named ranges are defined by ELCL and must be supported by all implementations:
Name
Definition
letters
a-z, A-Z
digits
0-9
control
U+0001–U+001F, U+007F–U+00A0
linebreak
U+000D, U+000A
spacing
U+0009, U+0020
Implementations may provide additional named ranges (for example, Unicode classes). Such extensions must not override built-in names.
To avoid ambiguity, custom ranges should use descriptive prefixes such as
unicode_letters.Case Sensitivity: Character matching is always case-sensitive, regardless of the case-sensitive flag.
Both uppercase and lowercase characters must be explicitly listed if required.
[server.name] type: "text" chars: "[a-z]", "[A-Z]"
Negation with ``not_chars``: When negated as
not_chars, the constraint specifies forbidden characters.Validation fails if any character in the text matches one of the forbidden sets.
Design Rationale
Negating the entire constraint naively would allow strings that merely contain at least one allowed character, which is unintuitive.
Instead,
not_charsmakes every occurrence of the forbidden characters invalid.Example:
not_chars: "(a-z)"rejects"123abc"because it contains forbidden lowercase letters.[server.name] type: "text" not_chars: "control" # Control characters are forbidden