@@ -382,6 +382,31 @@ Sometimes an existing member field may be renamed and/or moved. It is possible t
382382create alias names for the fields to keep the old client code being able to compile
383383and work. Please refer to <<aliases-aliases, Aliases>> chapter for more details.
384384
385+ [[messages-ensuring-serialization-length]]
386+ === Ensuring Serialization Length ===
387+ Many protocol specifications indicate the expected message serialization length, especially
388+ when message has fixed length. The **CommsDSL** allows specifying expected minimal length
389+ using **validateMinLength** property with <<intro-numeric, unsigned>> value to help avoid some copy-paste or typo errors
390+ at the time of schema parsing rather than debugging generated incorrect code.
391+ [source,xml]
392+ ----
393+ <?xml version="1.0" encoding="UTF-8"?>
394+ <schema ...>
395+ <message name="Msg1" id="1" validateMinLength="6">
396+ <int name="F1" type="uint32" />
397+ <int name="F2" type="int16" />
398+ <optional name="F3" defaultMode="exist">
399+ <int name="F3Field" type="uint8" />
400+ </optional>
401+ </message>
402+ </schema>
403+ ----
404+ Note, that <<fields-optional, <optional> >> field is always expected to have 0 minimal length regardless
405+ of its <<fields-optional-existence-conditions, existence conditions>>.
406+
407+ Also note, that the value of **validateMinLength** is the expected serialization length of
408+ message fields __without__ the fields of the <<frames-frames, <frame> >>.
409+
385410[[messages-ensuring-overriding-code-injection]]
386411=== Ensuring Overriding Code Injection ===
387412Similar to <<fields-common-ensuring-overriding-code-injection, fields>> the default code
0 commit comments