From da9898dc226bd0073e3c78913dd8947d4af3d3b8 Mon Sep 17 00:00:00 2001 From: MnPX Date: Thu, 30 Apr 2026 14:44:46 +1000 Subject: [PATCH 01/21] Fix "pstring" docs subsection header to include mention of "encoding" --- doc/datatypes/utils.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/datatypes/utils.md b/doc/datatypes/utils.md index c64a3aa..7292903 100644 --- a/doc/datatypes/utils.md +++ b/doc/datatypes/utils.md @@ -109,7 +109,7 @@ or Example of value to pass when writing: `{"flags": { "onGround": true, "inAir": false } }`. Likewise when reading you will get a similar object back, with a extra `_value` field holding the raw integer. -### **pstring** ({ countType: Type, ?count: Countable }) +### **pstring** ({ countType: Type, ?count: Countable, ?encoding: string }) Arguments: * countType : the type of the length prefix * count : optional (either count or countType), a reference to the field counting the elements, or a fixed size (an integer) From 5a390911ddc51b448f27fb77be1376bdfcf0426f Mon Sep 17 00:00:00 2001 From: MnPX Date: Thu, 30 Apr 2026 15:27:52 +1000 Subject: [PATCH 02/21] Fix "utils" markdown document to specify JSON as language of example JSON code-block - modifies language used to indicate what the numerals are --- doc/datatypes/utils.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/datatypes/utils.md b/doc/datatypes/utils.md index 7292903..511df1e 100644 --- a/doc/datatypes/utils.md +++ b/doc/datatypes/utils.md @@ -92,20 +92,22 @@ Example: ``` or -```yaml +```json [ "bitflags", { "type": "lu32", "big": true, "flags": { - "onGround": 0b1, - "inAir": 0b10 + "onGround": 1, + "inAir": 2 } } ] ``` +where `1` and `2` respectively are the JSON-compatible, decimal representations of the bitmasks `0b01` and `0b10`. + Example of value to pass when writing: `{"flags": { "onGround": true, "inAir": false } }`. Likewise when reading you will get a similar object back, with a extra `_value` field holding the raw integer. From 85b611b134dd1a350814b9e5a48d8bb46a10eb85 Mon Sep 17 00:00:00 2001 From: MnPX Date: Thu, 30 Apr 2026 15:41:39 +1000 Subject: [PATCH 03/21] Fix spacing on "pstring"'s "encoding" argument to conform to existing format --- doc/datatypes/utils.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/datatypes/utils.md b/doc/datatypes/utils.md index 511df1e..361a52e 100644 --- a/doc/datatypes/utils.md +++ b/doc/datatypes/utils.md @@ -115,7 +115,7 @@ Example of value to pass when writing: `{"flags": { "onGround": true, "inAir": f Arguments: * countType : the type of the length prefix * count : optional (either count or countType), a reference to the field counting the elements, or a fixed size (an integer) -* encoding: the encoding of the string, UTF-8 by default +* encoding : the encoding of the string, UTF-8 by default Represents a string. From 432d3cbdf9fc0c1bf21145e05947d5d85be4e73d Mon Sep 17 00:00:00 2001 From: MnPX Date: Thu, 30 Apr 2026 19:19:00 +1000 Subject: [PATCH 04/21] Fix 'langauge' typo --- doc/datatypes/utils.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/datatypes/utils.md b/doc/datatypes/utils.md index 361a52e..51c7cc4 100644 --- a/doc/datatypes/utils.md +++ b/doc/datatypes/utils.md @@ -74,7 +74,7 @@ Example of value: `"int"` Arguments: * type : The underlying integer type (eg varint, lu32). * flags : Either an array of flag values from LSB to MSB, or an object containing a mappng of valueName => bitMask. -* big : 64+ bits. In langauges like javascript (where all numbers are 64-bit floating points), special data types may have to be used for integers greater than 32 bits, so this must be set to true if the `type` is using the special data type. +* big : 64+ bits. In languages like javascript (where all numbers are 64-bit floating points), special data types may have to be used for integers greater than 32 bits, so this must be set to true if the `type` is using the special data type. * shift : Specify if flags is an object and holds bit positions as values opposed to a bitmask. Represents boolean flags packed into an integer. Similar to bitfields, but only intended for enumerated boolean flags (each flag occupies 1 bit), and supports arbitrary underlying integer types. From c050dcbe0c869b3fd15ed0efe0673c216cfd6a6c Mon Sep 17 00:00:00 2001 From: MnPX Date: Thu, 30 Apr 2026 19:20:43 +1000 Subject: [PATCH 05/21] Fix optionality qualifier at beginning of word in subsection header --- doc/datatypes/utils.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/datatypes/utils.md b/doc/datatypes/utils.md index 51c7cc4..ed5dd2f 100644 --- a/doc/datatypes/utils.md +++ b/doc/datatypes/utils.md @@ -70,7 +70,7 @@ Maps a byte to a string, 1 to "byte", 2 to "short", 3 to "int", 4 to "long". ``` Example of value: `"int"` -### **bitflags** ([ { type: string, flags: object | array, big?: boolean, shift?: number } ]) +### **bitflags** ([ { type: string, flags: object | array, ?big: boolean, ?shift: number } ]) Arguments: * type : The underlying integer type (eg varint, lu32). * flags : Either an array of flag values from LSB to MSB, or an object containing a mappng of valueName => bitMask. From 50e58ee94c83d57d372ee8348b4935766aae23f4 Mon Sep 17 00:00:00 2001 From: MnPX Date: Thu, 30 Apr 2026 19:25:07 +1000 Subject: [PATCH 06/21] Fix primitives doc "cstring" subsection header to include its arguments --- doc/datatypes/primitives.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/datatypes/primitives.md b/doc/datatypes/primitives.md index ddea505..3ec794e 100644 --- a/doc/datatypes/primitives.md +++ b/doc/datatypes/primitives.md @@ -7,7 +7,7 @@ Represents a boolean, encoded in one byte. Example of value: `true` / `false` -### **cstring** ( ) +### **cstring** ({ ?encoding: String }) Arguments: encoding Represents a null terminated string. Similar to strings in C. From ec8d8402acfd85e5b78014b8a88f91662cd92130 Mon Sep 17 00:00:00 2001 From: MnPX Date: Thu, 30 Apr 2026 19:27:33 +1000 Subject: [PATCH 07/21] Fix consistency on docs' subsection headers for types with no arguments --- doc/datatypes/numeric.md | 2 +- doc/datatypes/primitives.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/datatypes/numeric.md b/doc/datatypes/numeric.md index 9183861..46b6723 100644 --- a/doc/datatypes/numeric.md +++ b/doc/datatypes/numeric.md @@ -36,7 +36,7 @@ Example: ``` Example of value: `65535` (size = 2) / `16777215` (size = 3) -### **varint** ( ) +### **varint** () Arguments: None [Protobuf](https://developers.google.com/protocol-buffers/docs/encoding#varints)-compatible representation for variable-length integers using one or more bytes. Intended for 32-bit unsigned integers, or signed 32-bit integers that have been directly cast to an integer (where the MSB is the sign bit) before encoding. diff --git a/doc/datatypes/primitives.md b/doc/datatypes/primitives.md index 3ec794e..92ed71e 100644 --- a/doc/datatypes/primitives.md +++ b/doc/datatypes/primitives.md @@ -1,6 +1,6 @@ ## Primitives -### **bool** ( ) +### **bool** () Arguments: None Represents a boolean, encoded in one byte. @@ -23,7 +23,7 @@ Example: A string length prefixed by a varint. Example of value: `"my string"` -### **void** ( ) +### **void** () Arguments: None Represents an empty value. From e6eb764bfd224470e4be1c09597c28d9b6091510 Mon Sep 17 00:00:00 2001 From: MnPX Date: Thu, 30 Apr 2026 19:36:30 +1000 Subject: [PATCH 08/21] Fix consistency on how types are printed in subsection headers --- doc/datatypes/structures.md | 2 +- doc/datatypes/utils.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/datatypes/structures.md b/doc/datatypes/structures.md index 6beaefd..a64954b 100644 --- a/doc/datatypes/structures.md +++ b/doc/datatypes/structures.md @@ -20,7 +20,7 @@ Example: An array of int prefixed by a short length. ``` Example of value: `[1, 2, 3, 4]` (type = [i8](./numeric.md)) / `["ac", "dc"]` (type = [cstring](./utils.md)) -### **container** ([ { name: String, type: Type, ?anon: Bool }, ... ]) +### **container** ([ { name: String, type: Type, ?anon: Boolean }, ... ]) Arguments: * [array] : a field * * name : the name of field diff --git a/doc/datatypes/utils.md b/doc/datatypes/utils.md index ed5dd2f..933a0fe 100644 --- a/doc/datatypes/utils.md +++ b/doc/datatypes/utils.md @@ -70,7 +70,7 @@ Maps a byte to a string, 1 to "byte", 2 to "short", 3 to "int", 4 to "long". ``` Example of value: `"int"` -### **bitflags** ([ { type: string, flags: object | array, ?big: boolean, ?shift: number } ]) +### **bitflags** ([ { type: String, flags: Object | Array, ?big: Boolean, ?shift: Number } ]) Arguments: * type : The underlying integer type (eg varint, lu32). * flags : Either an array of flag values from LSB to MSB, or an object containing a mappng of valueName => bitMask. @@ -111,7 +111,7 @@ where `1` and `2` respectively are the JSON-compatible, decimal representations Example of value to pass when writing: `{"flags": { "onGround": true, "inAir": false } }`. Likewise when reading you will get a similar object back, with a extra `_value` field holding the raw integer. -### **pstring** ({ countType: Type, ?count: Countable, ?encoding: string }) +### **pstring** ({ countType: Type, ?count: Countable, ?encoding: String }) Arguments: * countType : the type of the length prefix * count : optional (either count or countType), a reference to the field counting the elements, or a fixed size (an integer) From 920e4cf2f94051737d694987a7af2aa1155e9d78 Mon Sep 17 00:00:00 2001 From: MnPX Date: Thu, 30 Apr 2026 19:38:02 +1000 Subject: [PATCH 09/21] Fix "cstring" example correctly describes what it is --- doc/datatypes/primitives.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/datatypes/primitives.md b/doc/datatypes/primitives.md index 92ed71e..0bd5c29 100644 --- a/doc/datatypes/primitives.md +++ b/doc/datatypes/primitives.md @@ -14,7 +14,7 @@ Represents a null terminated string. Similar to strings in C. Assumes UTF-8 encoding by default Example: -Example: A string length prefixed by a varint. +A UTF-16 string of unknown size that is expected to end with the zero character (null-terminal). ```json [ "cstring", { "encoding": "utf-16" } From 995c62538407ebfc8dc675a3223f70a8d89a0f45 Mon Sep 17 00:00:00 2001 From: MnPX Date: Thu, 30 Apr 2026 19:38:47 +1000 Subject: [PATCH 10/21] Fix null-termination grammar --- doc/datatypes/primitives.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/datatypes/primitives.md b/doc/datatypes/primitives.md index 0bd5c29..b5e6878 100644 --- a/doc/datatypes/primitives.md +++ b/doc/datatypes/primitives.md @@ -10,7 +10,7 @@ Example of value: `true` / `false` ### **cstring** ({ ?encoding: String }) Arguments: encoding -Represents a null terminated string. Similar to strings in C. +Represents a null-terminated string. Similar to strings in C. Assumes UTF-8 encoding by default Example: From 7958660670fd25ab7047f7de8fb2e5ef87b3eb92 Mon Sep 17 00:00:00 2001 From: MnPX Date: Thu, 30 Apr 2026 19:40:00 +1000 Subject: [PATCH 11/21] Fix "cstring" subsection "Arguments" list conforms to how other arguments are presented --- doc/datatypes/primitives.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/datatypes/primitives.md b/doc/datatypes/primitives.md index b5e6878..790c9eb 100644 --- a/doc/datatypes/primitives.md +++ b/doc/datatypes/primitives.md @@ -8,10 +8,10 @@ Represents a boolean, encoded in one byte. Example of value: `true` / `false` ### **cstring** ({ ?encoding: String }) -Arguments: encoding +Arguments: +* encoding : the encoding of the string, UTF-8 by default Represents a null-terminated string. Similar to strings in C. -Assumes UTF-8 encoding by default Example: A UTF-16 string of unknown size that is expected to end with the zero character (null-terminal). From a8a138dca619f3f9a2a6ea6264eb1ea760594bbf Mon Sep 17 00:00:00 2001 From: MnPX Date: Thu, 30 Apr 2026 19:41:45 +1000 Subject: [PATCH 12/21] Fix "Example" subsubsection header appends newline consistently --- doc/datatypes/conditional.md | 4 ++-- doc/datatypes/structures.md | 9 ++++++--- doc/datatypes/utils.md | 9 ++++----- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/doc/datatypes/conditional.md b/doc/datatypes/conditional.md index 4526c45..79249f7 100644 --- a/doc/datatypes/conditional.md +++ b/doc/datatypes/conditional.md @@ -15,7 +15,6 @@ For `compareTo` variables, to go up one level when referencing a field, use "../ Switch statement field names starting with "/" will reference a root variable. Root variables are primitives that can be used for comparisons and changed dynamically. Example: - A switch which can encode a byte, a varint, a float or a string depending on "someField". If the value of someField is different, then the value encoded is of type void. ```json @@ -43,7 +42,8 @@ Represents a simple optional type. It's encoded as a boolean indicating whether the value is there or not. It's similar to the `Optional` type in java or `Maybe` in haskell. -Example: An option of value string +Example: +An option of value string ```json [ "option", diff --git a/doc/datatypes/structures.md b/doc/datatypes/structures.md index a64954b..a55a713 100644 --- a/doc/datatypes/structures.md +++ b/doc/datatypes/structures.md @@ -8,7 +8,8 @@ Arguments: Represents a list of values with same type. -Example: An array of int prefixed by a short length. +Example: +An array of int prefixed by a short length. ```json [ "array", @@ -29,7 +30,8 @@ Arguments: Represents a list of named values. -Example: A container with fields of type int, int, ushort and ushort. +Example: +A container with fields of type int, int, ushort and ushort. ```json [ "container", @@ -57,7 +59,8 @@ Arguments: Represents a count field for an array or a buffer. -Example: A count for a field name records, of type short. +Example: +A count for a field name records, of type short. ```json [ "count", diff --git a/doc/datatypes/utils.md b/doc/datatypes/utils.md index 933a0fe..bd44d77 100644 --- a/doc/datatypes/utils.md +++ b/doc/datatypes/utils.md @@ -8,7 +8,8 @@ Arguments: Represents a raw bytes with count prefix/field or without it. -Example: An buffer prefixed by a varint length. +Example: +An buffer prefixed by a varint length. ```json [ "buffer", @@ -29,7 +30,6 @@ Represents a list of value with sizes that are not a multiple of 8bits. The sum of the sizes must be a multiple of 8. Example: - 3 values, x, y and z with sizes in bits : 26, 12, 26. Notice that 26+12+26=64. ```json [ @@ -52,7 +52,6 @@ Arguments: Maps string to a values. Example: - Maps a byte to a string, 1 to "byte", 2 to "short", 3 to "int", 4 to "long". ```json [ @@ -80,7 +79,6 @@ Arguments: Represents boolean flags packed into an integer. Similar to bitfields, but only intended for enumerated boolean flags (each flag occupies 1 bit), and supports arbitrary underlying integer types. Example: - ```json [ "bitflags", @@ -119,7 +117,8 @@ Arguments: Represents a string. -Example: A string length prefixed by a varint. +Example: +A string length prefixed by a varint. ```json [ "pstring", { "countType": "varint", "encoding": "utf-8" } From e5a56464927511ae9e8754641e8c9d19bde6114e Mon Sep 17 00:00:00 2001 From: MnPX Date: Thu, 30 Apr 2026 20:12:38 +1000 Subject: [PATCH 13/21] Fix "big" argument of "bitflags" type documentation to specify what the condition is --- doc/datatypes/utils.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/datatypes/utils.md b/doc/datatypes/utils.md index bd44d77..3a8a400 100644 --- a/doc/datatypes/utils.md +++ b/doc/datatypes/utils.md @@ -73,7 +73,7 @@ Example of value: `"int"` Arguments: * type : The underlying integer type (eg varint, lu32). * flags : Either an array of flag values from LSB to MSB, or an object containing a mappng of valueName => bitMask. -* big : 64+ bits. In languages like javascript (where all numbers are 64-bit floating points), special data types may have to be used for integers greater than 32 bits, so this must be set to true if the `type` is using the special data type. +* big : If the type is 64+ bits. In languages like javascript (where all numbers are 64-bit floating points), special data types may have to be used for integers greater than 32 bits, so this must be set to true if the `type` is using the special data type. * shift : Specify if flags is an object and holds bit positions as values opposed to a bitmask. Represents boolean flags packed into an integer. Similar to bitfields, but only intended for enumerated boolean flags (each flag occupies 1 bit), and supports arbitrary underlying integer types. From 7328f94e52506c01b33cbacbd1573ddfd78e9917 Mon Sep 17 00:00:00 2001 From: MnPX Date: Thu, 30 Apr 2026 22:40:02 +1000 Subject: [PATCH 14/21] Fix unnecessary array encapsulation is removed - this brings the schemas in line with the documentation --- schemas/numeric.json | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/schemas/numeric.json b/schemas/numeric.json index 9f9b264..5074e3e 100644 --- a/schemas/numeric.json +++ b/schemas/numeric.json @@ -82,18 +82,14 @@ "enum": ["int"] }, { - "type": "array", - "items": { - "type": "object", - "properties": { - "size": { - "type": "number" - } - }, - "required": ["size"], - "additionalProperties": false + "type": "object", + "properties": { + "size": { + "type": "number" + } }, - "additionalItems": false + "required": ["size"], + "additionalProperties": false } ], "additionalItems": false @@ -106,18 +102,14 @@ "enum": ["lint"] }, { - "type": "array", - "items": { - "type": "object", - "properties": { - "size": { - "type": "number" - } - }, - "required": ["size"], - "additionalProperties": false + "type": "object", + "properties": { + "size": { + "type": "number" + } }, - "additionalItems": false + "required": ["size"], + "additionalProperties": false } ], "additionalItems": false From 57a9ff400d024a22d0e6ff093cc82714257307b1 Mon Sep 17 00:00:00 2001 From: MnPX Date: Thu, 30 Apr 2026 22:40:02 +1000 Subject: [PATCH 15/21] Fix unnecessary array encapsulation is removed - this brings the schemas in line with the documentation --- schemas/numeric.json | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/schemas/numeric.json b/schemas/numeric.json index 9f9b264..5074e3e 100644 --- a/schemas/numeric.json +++ b/schemas/numeric.json @@ -82,18 +82,14 @@ "enum": ["int"] }, { - "type": "array", - "items": { - "type": "object", - "properties": { - "size": { - "type": "number" - } - }, - "required": ["size"], - "additionalProperties": false + "type": "object", + "properties": { + "size": { + "type": "number" + } }, - "additionalItems": false + "required": ["size"], + "additionalProperties": false } ], "additionalItems": false @@ -106,18 +102,14 @@ "enum": ["lint"] }, { - "type": "array", - "items": { - "type": "object", - "properties": { - "size": { - "type": "number" - } - }, - "required": ["size"], - "additionalProperties": false + "type": "object", + "properties": { + "size": { + "type": "number" + } }, - "additionalItems": false + "required": ["size"], + "additionalProperties": false } ], "additionalItems": false From 23f2fce1fa0f35c123749456304f535ee0555fdd Mon Sep 17 00:00:00 2001 From: MnPX Date: Thu, 30 Apr 2026 23:18:26 +1000 Subject: [PATCH 16/21] Fix schemas are consistently titled --- schemas/numeric.json | 25 +++++++++++++++++++++++++ schemas/primitives.json | 2 ++ 2 files changed, 27 insertions(+) diff --git a/schemas/numeric.json b/schemas/numeric.json index 9f9b264..c18426b 100644 --- a/schemas/numeric.json +++ b/schemas/numeric.json @@ -1,77 +1,102 @@ { "i8": { + "title": "i8", "enum": ["i8"] }, "u8": { + "title": "u8", "enum": ["u8"] }, "i16": { + "title": "i16", "enum": ["i16"] }, "u16": { + "title": "u16", "enum": ["u16"] }, "i32": { + "title": "i32", "enum": ["i32"] }, "u32": { + "title": "u32", "enum": ["u32"] }, "f32": { + "title": "f32", "enum": ["f32"] }, "f64": { + "title": "f64", "enum": ["f64"] }, "li8": { + "title": "li8", "enum": ["li8"] }, "lu8": { + "title": "lu8", "enum": ["lu8"] }, "li16": { + "title": "li16", "enum": ["li16"] }, "lu16": { + "title": "lu16", "enum": ["lu16"] }, "li32": { + "title": "li32", "enum": ["li32"] }, "lu32": { + "title": "lu32", "enum": ["lu32"] }, "lf32": { + "title": "lf32", "enum": ["lf32"] }, "lf64": { + "title": "lf64", "enum": ["lf64"] }, "i64": { + "title": "i64", "enum": ["i64"] }, "li64": { + "title": "li64", "enum": ["li64"] }, "u64": { + "title": "u64", "enum": ["u64"] }, "lu64": { + "title": "lu64", "enum": ["lu64"] }, "varint": { + "title": "varint", "enum": ["varint"] }, "varint64": { + "title": "varint64", "enum": ["varint64"] }, "varint128": { + "title": "varint128", "enum": ["varint128"] }, "zigzag32": { + "title": "zigzag32", "enum": ["zigzag32"] }, "zigzag64": { + "title": "zigzag64", "enum": ["zigzag64"] }, "int": { diff --git a/schemas/primitives.json b/schemas/primitives.json index c5359ea..b5af6ab 100644 --- a/schemas/primitives.json +++ b/schemas/primitives.json @@ -1,5 +1,6 @@ { "bool": { + "title": "bool", "enum": ["bool"] }, "cstring": { @@ -23,6 +24,7 @@ "additionalItems": false }, "void": { + "title": "void", "enum": ["void"] } } From 71bd3099056a9bb5e0b280bd4aa13c15798b7dd7 Mon Sep 17 00:00:00 2001 From: MnPX Date: Thu, 30 Apr 2026 21:46:36 +1000 Subject: [PATCH 17/21] Add `minimum` and `maximum` arguments to integer types' documentation --- doc/datatypes/numeric.md | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/doc/datatypes/numeric.md b/doc/datatypes/numeric.md index 46b6723..a9abbd9 100644 --- a/doc/datatypes/numeric.md +++ b/doc/datatypes/numeric.md @@ -21,9 +21,11 @@ They default to big-endian encoding. To use little-endian, prefix its name with | zigzag32 | 1-4 | -100 | signed int var | | zigzag64 | 1-8 | -680n | signed long | -### **int** ({ size: Integer }) +### **int** ({ size: Integer, ?minimum: Integer, ?maximum: Integer }) Arguments: * size : fixed size in bytes +* minimum : optional, the minimum integer value +* maximum : optional, the maximum integer value Represents a unsigned integer using `size` bytes. @@ -31,34 +33,42 @@ Example: ```json [ "int", - { "size": "3" } + { "size": "3", "minimum": 14, "maximum": 15 } ] ``` Example of value: `65535` (size = 2) / `16777215` (size = 3) -### **varint** () +### **varint** ({ ?minimum: Integer, ?maximum: Integer }) Arguments: None [Protobuf](https://developers.google.com/protocol-buffers/docs/encoding#varints)-compatible representation for variable-length integers using one or more bytes. Intended for 32-bit unsigned integers, or signed 32-bit integers that have been directly cast to an integer (where the MSB is the sign bit) before encoding. Example of value: `300` (size is 2 bytes) -### **varint64** () -Arguments: None +### **varint64** ({ ?minimum: Integer, ?maximum: Integer }) +Arguments: +* minimum : optional, the minimum integer value +* maximum : optional, the maximum integer value Same as **varint**, but for 64-bit unsigned integers, or signed 64-bit integers that have been directly cast to an integer (where the MSB is the sign bit) before encoding. -### **varint128** () -Arguments: None +### **varint128** ({ ?minimum: Integer, ?maximum: Integer }) +Arguments: +* minimum : optional, the minimum integer value +* maximum : optional, the maximum integer value Same as **varint**, but for 128-bit unsigned integers, or signed 128-bit integers that have been directly cast to an integer (where the MSB is the sign bit) before encoding. -### **zigzag32** () -Arguments: None +### **zigzag32** ({ ?minimum: Integer, ?maximum: Integer }) +Arguments: +* minimum : optional, the minimum integer value +* maximum : optional, the maximum integer value Similar to **varint**, except using [ZigZag encoding](https://protobuf.dev/programming-guides/encoding/#signed-ints) for signed integers. Intended for 32-bit signed numbers. -### **zigzag64** () -Arguments: None +### **zigzag64** ({ ?minimum: Integer, ?maximum: Integer }) +Arguments: +* minimum : optional, the minimum integer value +* maximum : optional, the maximum integer value Same as **zigzag32**, but for 64-bit signed integers in ZigZag encoding. From 9440e286a30960ab177680b1dbaa0546199b4ce3 Mon Sep 17 00:00:00 2001 From: MnPX Date: Thu, 30 Apr 2026 21:47:14 +1000 Subject: [PATCH 18/21] Add example for `minimum` and `maximum` arguments to "int" type's subsection --- doc/datatypes/numeric.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/datatypes/numeric.md b/doc/datatypes/numeric.md index a9abbd9..3b159ed 100644 --- a/doc/datatypes/numeric.md +++ b/doc/datatypes/numeric.md @@ -38,6 +38,15 @@ Example: ``` Example of value: `65535` (size = 2) / `16777215` (size = 3) +Example: +```json +[ + "int", + { "size": "1", "minimum": 1, "maximum": 100 } +] +``` +Example of value: `1`, `100` (does not match `0` or `101`) + ### **varint** ({ ?minimum: Integer, ?maximum: Integer }) Arguments: None From d8b379e2dad6a38762d6cbdef8819e349c39296d Mon Sep 17 00:00:00 2001 From: MnPX Date: Thu, 30 Apr 2026 23:00:43 +1000 Subject: [PATCH 19/21] Add more JSON examples to "varint" doc --- doc/datatypes/numeric.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/doc/datatypes/numeric.md b/doc/datatypes/numeric.md index 3b159ed..dc02205 100644 --- a/doc/datatypes/numeric.md +++ b/doc/datatypes/numeric.md @@ -52,6 +52,33 @@ Arguments: None [Protobuf](https://developers.google.com/protocol-buffers/docs/encoding#varints)-compatible representation for variable-length integers using one or more bytes. Intended for 32-bit unsigned integers, or signed 32-bit integers that have been directly cast to an integer (where the MSB is the sign bit) before encoding. +Example: +```json +"varint" +``` + +or +```json +[ + "varint" +] +``` + +or +```json +[ + "varint", + {} +] +``` + +or +```json +[ + "varint", + { "minimum": 1, "maximum": 100 } +] +``` Example of value: `300` (size is 2 bytes) ### **varint64** ({ ?minimum: Integer, ?maximum: Integer }) From 2981751b6d5cea304b6340ff734cc016ff2f1354 Mon Sep 17 00:00:00 2001 From: MnPX Date: Thu, 30 Apr 2026 23:02:21 +1000 Subject: [PATCH 20/21] Update schemas for optionally settable integer arguments --- schemas/numeric.json | 700 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 675 insertions(+), 25 deletions(-) diff --git a/schemas/numeric.json b/schemas/numeric.json index da896da..83f0194 100644 --- a/schemas/numeric.json +++ b/schemas/numeric.json @@ -1,103 +1,753 @@ { "i8": { "title": "i8", - "enum": ["i8"] + "oneOf": [ + { + "enum": ["i8"] + }, + { + "type": "array", + "items": [ + { + "enum": ["i8"] + }, + { + "type": "object", + "properties": { + "minimum": { + "type": "number" + }, + "maximum": { + "type": "number" + } + }, + "required": [], + "additionalProperties": false + } + ], + "additionalItems": false + } + ] }, "u8": { "title": "u8", - "enum": ["u8"] + "oneOf": [ + { + "enum": ["u8"] + }, + { + "type": "array", + "items": [ + { + "enum": ["u8"] + }, + { + "type": "object", + "properties": { + "minimum": { + "type": "number" + }, + "maximum": { + "type": "number" + } + }, + "required": [], + "additionalProperties": false + } + ], + "additionalItems": false + } + ] }, "i16": { "title": "i16", - "enum": ["i16"] + "oneOf": [ + { + "enum": ["i16"] + }, + { + "type": "array", + "items": [ + { + "enum": ["i16"] + }, + { + "type": "object", + "properties": { + "minimum": { + "type": "number" + }, + "maximum": { + "type": "number" + } + }, + "required": [], + "additionalProperties": false + } + ], + "additionalItems": false + } + ] }, "u16": { "title": "u16", - "enum": ["u16"] + "oneOf": [ + { + "enum": ["u16"] + }, + { + "type": "array", + "items": [ + { + "enum": ["u16"] + }, + { + "type": "object", + "properties": { + "minimum": { + "type": "number" + }, + "maximum": { + "type": "number" + } + }, + "required": [], + "additionalProperties": false + } + ], + "additionalItems": false + } + ] }, "i32": { "title": "i32", - "enum": ["i32"] + "oneOf": [ + { + "enum": ["i32"] + }, + { + "type": "array", + "items": [ + { + "enum": ["i32"] + }, + { + "type": "object", + "properties": { + "minimum": { + "type": "number" + }, + "maximum": { + "type": "number" + } + }, + "required": [], + "additionalProperties": false + } + ], + "additionalItems": false + } + ] }, "u32": { "title": "u32", - "enum": ["u32"] + "oneOf": [ + { + "enum": ["u32"] + }, + { + "type": "array", + "items": [ + { + "enum": ["u32"] + }, + { + "type": "object", + "properties": { + "minimum": { + "type": "number" + }, + "maximum": { + "type": "number" + } + }, + "required": [], + "additionalProperties": false + } + ], + "additionalItems": false + } + ] }, "f32": { "title": "f32", - "enum": ["f32"] + "oneOf": [ + { + "enum": ["f32"] + }, + { + "type": "array", + "items": [ + { + "enum": ["f32"] + }, + { + "type": "object", + "properties": { + "minimum": { + "type": "number" + }, + "maximum": { + "type": "number" + } + }, + "required": [], + "additionalProperties": false + } + ], + "additionalItems": false + } + ] }, "f64": { "title": "f64", - "enum": ["f64"] + "oneOf": [ + { + "enum": ["f64"] + }, + { + "type": "array", + "items": [ + { + "enum": ["f64"] + }, + { + "type": "object", + "properties": { + "minimum": { + "type": "number" + }, + "maximum": { + "type": "number" + } + }, + "required": [], + "additionalProperties": false + } + ], + "additionalItems": false + } + ] }, "li8": { "title": "li8", - "enum": ["li8"] + "oneOf": [ + { + "enum": ["li8"] + }, + { + "type": "array", + "items": [ + { + "enum": ["li8"] + }, + { + "type": "object", + "properties": { + "minimum": { + "type": "number" + }, + "maximum": { + "type": "number" + } + }, + "required": [], + "additionalProperties": false + } + ], + "additionalItems": false + } + ] }, "lu8": { "title": "lu8", - "enum": ["lu8"] + "oneOf": [ + { + "enum": ["lu8"] + }, + { + "type": "array", + "items": [ + { + "enum": ["lu8"] + }, + { + "type": "object", + "properties": { + "minimum": { + "type": "number" + }, + "maximum": { + "type": "number" + } + }, + "required": [], + "additionalProperties": false + } + ], + "additionalItems": false + } + ] }, "li16": { "title": "li16", - "enum": ["li16"] + "oneOf": [ + { + "enum": ["li16"] + }, + { + "type": "array", + "items": [ + { + "enum": ["li16"] + }, + { + "type": "object", + "properties": { + "minimum": { + "type": "number" + }, + "maximum": { + "type": "number" + } + }, + "required": [], + "additionalProperties": false + } + ], + "additionalItems": false + } + ] }, "lu16": { "title": "lu16", - "enum": ["lu16"] + "oneOf": [ + { + "enum": ["lu16"] + }, + { + "type": "array", + "items": [ + { + "enum": ["lu16"] + }, + { + "type": "object", + "properties": { + "minimum": { + "type": "number" + }, + "maximum": { + "type": "number" + } + }, + "required": [], + "additionalProperties": false + } + ], + "additionalItems": false + } + ] }, "li32": { "title": "li32", - "enum": ["li32"] + "oneOf": [ + { + "enum": ["li32"] + }, + { + "type": "array", + "items": [ + { + "enum": ["li32"] + }, + { + "type": "object", + "properties": { + "minimum": { + "type": "number" + }, + "maximum": { + "type": "number" + } + }, + "required": [], + "additionalProperties": false + } + ], + "additionalItems": false + } + ] }, "lu32": { "title": "lu32", - "enum": ["lu32"] + "oneOf": [ + { + "enum": ["lu32"] + }, + { + "type": "array", + "items": [ + { + "enum": ["lu32"] + }, + { + "type": "object", + "properties": { + "minimum": { + "type": "number" + }, + "maximum": { + "type": "number" + } + }, + "required": [], + "additionalProperties": false + } + ], + "additionalItems": false + } + ] }, "lf32": { "title": "lf32", - "enum": ["lf32"] + "oneOf": [ + { + "enum": ["lf32"] + }, + { + "type": "array", + "items": [ + { + "enum": ["lf32"] + }, + { + "type": "object", + "properties": { + "minimum": { + "type": "number" + }, + "maximum": { + "type": "number" + } + }, + "required": [], + "additionalProperties": false + } + ], + "additionalItems": false + } + ] }, "lf64": { "title": "lf64", - "enum": ["lf64"] + "oneOf": [ + { + "enum": ["lf64"] + }, + { + "type": "array", + "items": [ + { + "enum": ["lf64"] + }, + { + "type": "object", + "properties": { + "minimum": { + "type": "number" + }, + "maximum": { + "type": "number" + } + }, + "required": [], + "additionalProperties": false + } + ], + "additionalItems": false + } + ] }, "i64": { "title": "i64", - "enum": ["i64"] + "oneOf": [ + { + "enum": ["i64"] + }, + { + "type": "array", + "items": [ + { + "enum": ["i64"] + }, + { + "type": "object", + "properties": { + "minimum": { + "type": "number" + }, + "maximum": { + "type": "number" + } + }, + "required": [], + "additionalProperties": false + } + ], + "additionalItems": false + } + ] }, "li64": { "title": "li64", - "enum": ["li64"] + "oneOf": [ + { + "enum": ["li64"] + }, + { + "type": "array", + "items": [ + { + "enum": ["li64"] + }, + { + "type": "object", + "properties": { + "minimum": { + "type": "number" + }, + "maximum": { + "type": "number" + } + }, + "required": [], + "additionalProperties": false + } + ], + "additionalItems": false + } + ] }, "u64": { "title": "u64", - "enum": ["u64"] + "oneOf": [ + { + "enum": ["u64"] + }, + { + "type": "array", + "items": [ + { + "enum": ["u64"] + }, + { + "type": "object", + "properties": { + "minimum": { + "type": "number" + }, + "maximum": { + "type": "number" + } + }, + "required": [], + "additionalProperties": false + } + ], + "additionalItems": false + } + ] }, "lu64": { "title": "lu64", - "enum": ["lu64"] + "oneOf": [ + { + "enum": ["lu64"] + }, + { + "type": "array", + "items": [ + { + "enum": ["lu64"] + }, + { + "type": "object", + "properties": { + "minimum": { + "type": "number" + }, + "maximum": { + "type": "number" + } + }, + "required": [], + "additionalProperties": false + } + ], + "additionalItems": false + } + ] }, "varint": { "title": "varint", - "enum": ["varint"] + "oneOf": [ + { + "enum": ["varint"] + }, + { + "type": "array", + "items": [ + { + "enum": ["varint"] + }, + { + "type": "object", + "properties": { + "minimum": { + "type": "number" + }, + "maximum": { + "type": "number" + } + }, + "required": [], + "additionalProperties": false + } + ], + "additionalItems": false + } + ] }, "varint64": { "title": "varint64", - "enum": ["varint64"] + "oneOf": [ + { + "enum": ["varint64"] + }, + { + "type": "array", + "items": [ + { + "enum": ["varint64"] + }, + { + "type": "object", + "properties": { + "minimum": { + "type": "number" + }, + "maximum": { + "type": "number" + } + }, + "required": [], + "additionalProperties": false + } + ], + "additionalItems": false + } + ] }, "varint128": { "title": "varint128", - "enum": ["varint128"] + "oneOf": [ + { + "enum": ["varint128"] + }, + { + "type": "array", + "items": [ + { + "enum": ["varint128"] + }, + { + "type": "object", + "properties": { + "minimum": { + "type": "number" + }, + "maximum": { + "type": "number" + } + }, + "required": [], + "additionalProperties": false + } + ], + "additionalItems": false + } + ] }, "zigzag32": { "title": "zigzag32", - "enum": ["zigzag32"] + "oneOf": [ + { + "enum": ["zigzag32"] + }, + { + "type": "array", + "items": [ + { + "enum": ["zigzag32"] + }, + { + "type": "object", + "properties": { + "minimum": { + "type": "number" + }, + "maximum": { + "type": "number" + } + }, + "required": [], + "additionalProperties": false + } + ], + "additionalItems": false + } + ] }, "zigzag64": { "title": "zigzag64", - "enum": ["zigzag64"] + "oneOf": [ + { + "enum": ["zigzag64"] + }, + { + "type": "array", + "items": [ + { + "enum": ["zigzag64"] + }, + { + "type": "object", + "properties": { + "minimum": { + "type": "number" + }, + "maximum": { + "type": "number" + } + }, + "required": [], + "additionalProperties": false + } + ], + "additionalItems": false + } + ] }, "int": { "title": "int", From 6a88164e6ff62f0c09ef40b51d6b8f4faba22158 Mon Sep 17 00:00:00 2001 From: MnPX Date: Sat, 2 May 2026 14:03:22 +1000 Subject: [PATCH 21/21] Fix missing maximum and minimum schemas on sized integers --- schemas/numeric.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/schemas/numeric.json b/schemas/numeric.json index 83f0194..a33f114 100644 --- a/schemas/numeric.json +++ b/schemas/numeric.json @@ -761,6 +761,12 @@ "properties": { "size": { "type": "number" + }, + "minimum": { + "type": "number" + }, + "maximum": { + "type": "number" } }, "required": ["size"], @@ -781,6 +787,12 @@ "properties": { "size": { "type": "number" + }, + "minimum": { + "type": "number" + }, + "maximum": { + "type": "number" } }, "required": ["size"],