Validation commands ([schema/cmds]) are pretty low-level and are inconvenient to write by hand. tcl/schema.tcl utility gives ability to convert much more nicer schemas written on Tcl language to the KEKS-encoded commands. We call those Tcl-written schemas "KEKS/Schema". Example with "our" structure (from [schema/cmds]) can be written as: ai {{field . {str} >0}} fpr {{field . {bin} len=32}} our { {field . {map}} {field a {with ai}} {field v {bin str}} {field fpr {with fpr}} {field comment {str} optional} } "wheres" as: latitude {{field . {int} >-91 <91}} longitude {{field . {int} >-181 <181}} where { {field . {list} len=2} {field 0 {with latitude}} {field 1 {with longitude}} } wheres {{field . {list} {of where} >0}} And [cm/pub/] as: pub { {field . {map}} {field load {with load}} {field sigs {list} {of sig} >0 optional} {field pubs {list} {of pub} >0 optional} } load { {field . {map}} {field t {str} =pub} {field v {with pub-load}} } av { {field . {map}} {field a {str} >0} {field v {bin}} } sig { {field . {map}} {field tbs {with pub-sig-tbs}} {field sign {with av}} } schema-include fpr.tcl schema-include pub-load.tcl schema-include pub-sig-tbs.tcl fpr {{field . {bin} len=32}} pub-load { {field . {map}} {field id {with fpr}} {field crit {} !exists} {field ku {set} >0 optional} {field pub {list} {of av} >0} {field sub {map} {of type str} >0} } exp-tai {{field . {tai} prec=s utc}} expiration {{field . {list} {of exp-tai} len=2}} pub-sig-tbs { {field . {map}} {field sid {with fpr}} {field cid {hexlet}} {field exp {with expiration}} {field nonce {bin} >0 optional} {field when {tai} utc prec=ms optional} } schema.tcl calls "schemas {s0 cmds0 s1 cmds1 ...}" command to produce an encoded map with "cmds*" commands for "s*" schemas. "field" command helps creation of commands related to the field. {field N {T ...} [optional] [!exists] [{of type T}] [{of S}] [>n] [<n] [len=n] [=v] [prec=p] [utc]} "N" required argument is the name of the field to consider. Either it is ".", meaning the current taken element by schema. Or it is a digit, meaning the n-th element of the list. Otherwise it is a name of the key in map. If N starts with ":", then its remaining part is a string anyway, giving you ability to specify ":2" for choosing the "2" key of map for example. "T" required argument is: * either a list of whitespace-separated allowable types (bin, blob, bool, hexlet, int, list, magic, map, nil, str, tai) * or {set}, that will assure the field is a map with NIL values * or {with S} string, that will issue the {SCHEMA S} command instead of type checking the field All other arguments are optional. By default, if no "optional" argument is specified, then explicit EXISTS check is called for the field. If "!exists" argument is specified, then it is explicitly checked to be non-existent and you can specify empty list of types in second argument. ">n" and "<n" arguments allow checking of the integer's value or the bin/str/list/map lengths. ">0" assures that either list/map or strings are not empty. "len=n" checks the exact length of bin/str/list/map, or integer's value. "=v" checks that given bin/str/hexlet/magic has specified binary value. "prec=p" issues TIMEPREC command, but instead of specifying the raw integer values, you choose one of: s, ms, us, ns, ps, fs. "utc" issues UTC command. {of S} argument issues checking of EACH element of the list or map against the specified schema "S". {of type T [T ...]} argument issues checking of EACH element of the list or map against the specified types. "schema-include filename.tcl" command used instead of "field" allows inclusion of the specified file with the path relative to given schema file.