## The one copy of the text rules of DESIGN 6.5: a stored text field is trimmed, 1..maxLen code ## points and free of control characters. Shared by the token/character names (tokens.nim) and the ## property keys (props.nim), so the two cannot drift apart. import std/unicode proc hasControlChar*(s: string): bool = for r in s.runes: if r.int < 0x20 or r.int == 0x7f: return true proc validText*(s: string, maxLen: int): bool = ## Trimmed, 1..maxLen code points, no control characters. NFC normalisation and the per-player ## uniqueness rule arrived with the name machinery of slice 8 (#23). s.len > 0 and s == s.strip and s.runeLen in 1 .. maxLen and not hasControlChar(s)