「‍」 Lingenic

HSV Schema beta

Type definitions in HSV format

Two Modes

ModeHeader ContainsBehaviorStatus
OpenNo type definitionsApplication defines meaning freely✓ v1.0 standard
TypedType definitionsTypes MUST be enforcedbeta

Open mode is the default HSV behavior defined in the core spec. This page defines the beta Typed extension: if a header contains type definitions, conforming applications must validate data against them.

What Typed Mode Enables

Type safety: Validation at parse time. Code generation for typed languages. Type coercion ("30" → integer 30).

Rich types: rational for exact fractions (1/2, 22/7)—no floating point errors. binary for raw bytes. Standard formats: email, uri, date, datetime, uuid.

Constraints: required, min, max, minlen, maxlen, pattern, enum, items.

Self-describing data: Schema travels with the data in the header. External schema references via URL. No separate schema file needed.

Structured content: HTML/XML-like content via namespace prefixes. No escaping for quotes, angles, ampersands.

Header is the Schema

Header defines structure, body contains data.

HSV uses HSV to describe HSV. Keys are field names, values are types:

[SOH] hsv [US] 1.0 [RS] name [US] string [RS] age [US] int [RS] email [US] string [STX] name [US] Alice [RS] age [US] 30 [RS] email [US] a@b.com [ETX]
Header KeyHeader ValueData KeyData Value
namestringnameAlice
ageintage30
emailstringemaila@b.com

With Constraints

For richer type definitions, use nested values:

[SOH] hsv [US] 1.0 [RS] name [US] [SSA] type [US] string [RS] required [US] true [ESA] [RS] age [US] [SSA] type [US] int [RS] min [US] 0 [ESA] [RS] email [US] [SSA] type [US] string [RS] format [US] email [ESA] [STX] name [US] Alice [RS] age [US] 30 [RS] email [US] a@b.com [ETX]

Simple types use plain values (string, int). Constrained types use nested structures.

Detecting Schema Mode

A header is a schema if any value is a recognized type name (string, int, float, rational, bool, array, object, binary) or a nested structure (SSA...ESA) containing type [US] .

Reserved header keys (not type definitions):

Schema Reference

Reference an external schema with the reserved hsv.schema key:

[SOH] hsv [US] 1.0 [RS] hsv.schema [US] https://example.com/user.hsv [STX] name [US] Alice [RS] age [US] 30 [ETX]

The URL returns an HSV document whose header defines the schema.

Type System

TypeDescriptionExample Values
stringUTF-8 text (default)Alice, hello world
intInteger42, -7
floatFloating point (IEEE 754)3.14, -0.5, 1.5e-10
rationalExact fraction1/2, -3/4, 22/7
boolBooleantrue, false
arrayGS-separated lista [GS] b [GS] c
objectNested structureSSA...ESA
binaryDLE-transparent bytes[DLE] [STX] ... [DLE] [ETX]

Fields can be absent or empty by default. Use required [US] true to mandate a non-empty value.

Type Constraints

ConstraintApplies ToMeaning
required [US] trueAnyMust have non-empty value
min [US] Nint, float, rationalMinimum value
max [US] Nint, float, rationalMaximum value
minlen [US] Nstring, arrayMinimum length
maxlen [US] Nstring, arrayMaximum length
pattern [US] regexstringMust match regex
format [US] namestringSemantic format (see below)
enum [US] a [GS] b [GS] cAnyValue must be one of listed
items [US] typearrayType of array elements
default [US] valueAnyDefault if absent

Standard Formats

FormatDescriptionExample
emailEmail addressuser@example.com
uriURI/URLhttps://example.com
dateISO 8601 date2026-01-27
timeISO 8601 time14:30:00
datetimeISO 8601 datetime2026-01-27T14:30:00Z
uuidUUID550e8400-e29b-41d4-a716-446655440000
base64Base64 encodedSGVsbG8=

Notes

object: Nested object schema (defining properties of nested structures) is not yet specified. Use object type to indicate nesting; validation of nested content is application-defined.

binary: Only required constraint applies. Content validation is application-defined.

Full Example

A user record with typed schema in the header:

[SOH] hsv [US] 1.0 [RS]
  id [US] [SSA] type [US] int [RS] required [US] true [RS] min [US] 1 [ESA] [RS]
  name [US] [SSA] type [US] string [RS] required [US] true [RS] maxlen [US] 100 [ESA] [RS]
  email [US] [SSA] type [US] string [RS] format [US] email [ESA] [RS]
  role [US] [SSA] type [US] string [RS] enum [US] admin [GS] user [GS] guest [RS] default [US] user [ESA] [RS]
  tags [US] [SSA] type [US] array [RS] items [US] string [ESA] [RS]
  profile [US] object
[STX] id [US] 1 [RS] name [US] Alice [RS] email [US] alice@example.com [RS] role [US] admin [RS] tags [US] staff [GS] engineering [RS] profile [US] [SSA] bio [US] Engineer [RS] location [US] NYC [ESA] [ETX]

The header maps field names to their types. Simple fields use plain type names (object), constrained fields use nested definitions.

Validation

When a header contains type definitions, conforming applications must:

  1. Parse the header to extract field types
  2. Parse each record
  3. Validate each field against its type definition
  4. Reject invalid data or report errors with field path and constraint violated

Data without typed headers is schema-free HSV—no validation required.

Schema-Only Documents

Standalone schema files (referenced via hsv.schema) contain only a header:

[SOH] hsv [US] 1.0 [RS]
  id [US] [SSA] type [US] int [RS] required [US] true [ESA] [RS]
  name [US] [SSA] type [US] string [RS] required [US] true [ESA] [RS]
  email [US] [SSA] type [US] string [RS] format [US] email [ESA]
[STX] [ETX]

Empty body, schema in header. The file extension .hsv is sufficient.

Summary

Two modes, one format:

Schema syntax:

HSV Schema uses HSV format. Same parser, same benefits.