# ESType: ECMAScript types for JSON Schema

Version: 0.1.0 · Status: draft · License: Apache-2.0

Source: lingodata/estype@0cbfb46

## 0. Introduction

ESType is a [JSON Schema](https://json-schema.org/draft/2020-12/json-schema-core) vocabulary that states the JavaScript (ECMAScript) type of a value. It is part of the **LingoData** family of specifications for data interoperability.

JSON Schema describes JSON documents, and JSON has no dates, big integers, sets, maps or binary data. The same date can travel as a plain JSON string or as an [ECSON](https://github.com/lingodata/ecson) typed value (`{ "$date": "..." }`). With ESType, a schema declares the type of the value once, accepts both forms, and lets libraries convert the value to the native type. ESType is unrelated to the `jstype` option of Protocol Buffers ([section 5.3](#53-informative-references)).

> **Tip (non-normative): Example**
>
> ```json
> { "type": "string", "format": "date-time", "estype": "date" }
> ```
> accepts, once compiled ([section 2](#2-compilation)), `"2026-11-13T10:00:00.000Z"` and `{ "$date": "2026-11-13T10:00:00.000Z" }`, and a library that reads it with the schema produces a `Date`.

### 0.1 Conventions

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 ([RFC 2119](https://www.rfc-editor.org/rfc/rfc2119), [RFC 8174](https://www.rfc-editor.org/rfc/rfc8174)) when, and only when, they appear in all capitals, as shown here.

### 0.2 Terminology

- **ES type**: a type that ECSON serializes and that `estype` can name ([`ESTYPE_KEYWORD`](#ESTYPE_KEYWORD), [`ESTYPE_EXCLUDED`](#ESTYPE_EXCLUDED)), identified by its ECSON tag without `$` (for example `date` for `$date`).
- **ECSON form**: the typed value that ECSON uses to represent the value ([ECSON section 1](./ecson.md#1-typed-values)).
- **Plain JSON form**: the JSON value of a value without ECSON ([ECSON section 5.3](./ecson.md#53-plain-json-form)).
- **Native value**: the value in the native type of the host language (for example a JavaScript `Date`).
- **Declared schema**: the keywords of a subschema other than `estype`, as written by the author of the schema.
- **ECSON branch**, **plain branch** and **exclusion schema**: the parts of a compiled subschema ([`COMPILE_ECSON_BRANCH`](#COMPILE_ECSON_BRANCH), [`COMPILE_PLAIN_BRANCH`](#COMPILE_PLAIN_BRANCH)).
- **Default plain schema**: the schema of the table in [section 2.1](#21-default-plain-schemas) used for the plain branch when the declared schema has no keyword other than those of [`COMPILE_OUTSIDE_KEYWORDS`](#COMPILE_OUTSIDE_KEYWORDS) ([`COMPILE_PLAIN_BRANCH`](#COMPILE_PLAIN_BRANCH)).
- **Compiled subschema**: the result of compiling a subschema with `estype` ([`COMPILE_REWRITE`](#COMPILE_REWRITE)).
- **Converter**: an implementation that meets the Converter level ([section 5.1](#51-conformance)).
- **Path** of a value: the location of the value in the document, from its root.

### 0.3 Versioning

<a id="SPEC_SEMVER"></a>**Rule `SPEC_SEMVER`**: MUST

This specification MUST be versioned independently of the other specifications of the LingoData family, following [Semantic Versioning 2.0.0](https://semver.org/).

> **Note (non-normative)**
>
> While this specification is in a `0.x` version, any release may contain incompatible changes, as allowed by Semantic Versioning.

## 1. Vocabulary

<a id="ESTYPE_KEYWORD"></a>**Rule `ESTYPE_KEYWORD`**: MUST

The value of the `estype` keyword MUST be a string naming one ES type: the tag, without the leading `$`, of a type of the ECSON core type set, of an official ECSON extension type set, or of an application type with a namespace ([ECSON section 6](./ecson.md#6-tag-ownership-and-namespaces)). For an application type, `$` followed by the value MUST follow [ECSON `TAG_GRAMMAR`](./ecson.md#TAG_GRAMMAR).

<a id="ESTYPE_EXCLUDED"></a>**Rule `ESTYPE_EXCLUDED`**: MUST NOT

`estype` MUST NOT be `undefined`, `minKey`, `maxKey` or `class`.

> **Note (non-normative): Rationale**
>
> The plain JSON form of `undefined`, `minKey` and `maxKey` is `null` or an omitted member ([ECSON section 5.3](./ecson.md#53-plain-json-form)), and `null` is never converted ([`CONVERT_NULL`](#CONVERT_NULL)), so these types could not be read from the plain JSON form. `class` is not a type: it is the generic form of application classes ([ECSON section 5.4](./ecson.md#54-application-classes)).

> **Tip (non-normative): Example**
>
> Valid values: `date`, `bigint`, `map`, `plaindate`, `error`, `oid`, `rel`, `acme.money`. Not valid: `acme.` and `a..b` (the tags `$acme.` and `$a..b` break [`TAG_GRAMMAR`](./ecson.md#TAG_GRAMMAR)).

<a id="ESTYPE_VOCABULARY_URI"></a>**Rule `ESTYPE_VOCABULARY_URI`**: MUST

The vocabulary MUST be identified by the URI `https://lingodata.dev/estype/vocab/0.1`, declared with `$vocabulary` in meta-schemas that include it.

<a id="ESTYPE_META_SCHEMA_URI"></a>**Rule `ESTYPE_META_SCHEMA_URI`**: MUST

The meta-schema of the vocabulary MUST be identified by the URI `https://lingodata.dev/estype/meta/0.1`.

<a id="ESTYPE_DIALECT_URI"></a>**Rule `ESTYPE_DIALECT_URI`**: MUST

The dialect that adds this vocabulary to JSON Schema 2020-12 MUST be identified by the URI `https://lingodata.dev/estype/schema/0.1`.

<a id="ESTYPE_DIALECT_VOCABULARY"></a>**Rule `ESTYPE_DIALECT_VOCABULARY`**: MUST

The meta-schema of the dialect MUST declare the vocabulary in `$vocabulary` with the value `false`.

> **Note (non-normative)**
>
> A schema may declare the dialect in `$schema`. With `false`, a validator that does not know the vocabulary still processes schemas of the dialect, and treats `estype` as an annotation ([JSON Schema Core, section 8.1.2](https://json-schema.org/draft/2020-12/json-schema-core#section-8.1.2)); with `true`, it would refuse them.

> **Caution (non-normative): Provisional**
>
> The vocabulary, meta-schema and dialect URIs and the URI of the definitions document ([section 3](#3-definitions-document)) are provisional until the publication domain of the LingoData family is defined. This version does not yet specify the content of the meta-schema and dialect documents, beyond the rules of this section.

<a id="ESTYPE_SUBSCHEMA"></a>**Rule `ESTYPE_SUBSCHEMA`**: MUST NOT

A schema object that has `estype` MUST NOT also have a `$ref` whose target, directly or through further `$ref`, has `estype`.

<a id="ESTYPE_CONFLICT"></a>**Rule `ESTYPE_CONFLICT`**: MUST NOT

Two subschemas that apply to the same value MUST NOT have different `estype` values. The subschemas that apply to the same value as a subschema S are S itself and those reached from S through entries of `allOf` and through `$ref`, repeatedly and in any combination. The branches of `anyOf`, `oneOf` and `not` are not among them.

> **Tip (non-normative): Example**
>
> `{ "allOf": [{ "estype": "date" }, { "estype": "bigint" }] }` and `{ "estype": "date", "allOf": [{ "$ref": "#/$defs/n" }], "$defs": { "n": { "estype": "bigint" } } }` break the rule. `{ "anyOf": [{ "estype": "date" }, { "estype": "bigint" }] }` does not: its branches are alternatives.

> **Note (non-normative)**
>
> `estype` is a keyword of a schema object. JSON Schema recommends that implementations treat unknown keywords as annotations ([JSON Schema Core, section 6.5](https://json-schema.org/draft/2020-12/json-schema-core#section-6.5)). A generic validator that does not know ESType, including one that reads the dialect meta-schema ([`ESTYPE_DIALECT_VOCABULARY`](#ESTYPE_DIALECT_VOCABULARY)), validates only the declared schema; compiling the schema ([section 2](#2-compilation)) makes it accept the ECSON form too.

## 2. Compilation

Compiling a schema rewrites every subschema that has `estype` into a standard JSON Schema 2020-12 subschema that accepts the value in its ECSON form or in its plain JSON form, as described by the declared schema. A compiled schema accepts both forms in any validator that treats unknown keywords as annotations ([JSON Schema Core, section 6.5](https://json-schema.org/draft/2020-12/json-schema-core#section-6.5)), since `estype` stays in it ([`COMPILE_OUTSIDE_KEYWORDS`](#COMPILE_OUTSIDE_KEYWORDS)). A strict validator such as [Ajv](https://ajv.js.org/) must be configured to accept `estype` (for example with `ajv.addKeyword("estype")`).

<a id="COMPILE_REWRITE"></a>**Rule `COMPILE_REWRITE`**: MUST

Compilation MUST replace each subschema S with `estype` T by a subschema with the keyword `oneOf` holding two subschemas, the ECSON branch ([`COMPILE_ECSON_BRANCH`](#COMPILE_ECSON_BRANCH)) and the plain branch ([`COMPILE_PLAIN_BRANCH`](#COMPILE_PLAIN_BRANCH)), plus the keywords of S that stay outside ([`COMPILE_OUTSIDE_KEYWORDS`](#COMPILE_OUTSIDE_KEYWORDS)).

<a id="COMPILE_ECSON_BRANCH"></a>**Rule `COMPILE_ECSON_BRANCH`**: MUST

The ECSON branch MUST be `{ "type": "object", "required": [TAG], "properties": { TAG: true }, "additionalProperties": false }`, where TAG is the tag of T with its leading `$`.

<a id="COMPILE_PLAIN_BRANCH"></a>**Rule `COMPILE_PLAIN_BRANCH`**: MUST

The plain branch MUST be an `allOf` of two subschemas: the declared schema without the keywords that stay outside (or, when the declared schema has no keyword other than those of [`COMPILE_OUTSIDE_KEYWORDS`](#COMPILE_OUTSIDE_KEYWORDS), the default plain schema of T from the table below), and the exclusion schema `{ "not": E }`, where E is the ECSON branch.

<a id="COMPILE_NO_DEFAULT"></a>**Rule `COMPILE_NO_DEFAULT`**: MUST

When T has no default plain schema in the table below (for example an application type) and the declared schema has no keyword other than those of [`COMPILE_OUTSIDE_KEYWORDS`](#COMPILE_OUTSIDE_KEYWORDS), compilation MUST fail.

> **Note (non-normative)**
>
> The default plain schema is used only when the declared schema has no keyword other than those of [`COMPILE_OUTSIDE_KEYWORDS`](#COMPILE_OUTSIDE_KEYWORDS) ([`COMPILE_PLAIN_BRANCH`](#COMPILE_PLAIN_BRANCH)): it is never merged with declared keywords. With `{ "estype": "bigint", "minimum": 0 }` the plain branch holds only `{ "minimum": 0 }`, which accepts any string, so authors who declare keywords should also declare `type`.

<a id="COMPILE_INVALID_ESTYPE"></a>**Rule `COMPILE_INVALID_ESTYPE`**: MUST

Compilation MUST fail for a schema with an `estype` that breaks [`ESTYPE_KEYWORD`](#ESTYPE_KEYWORD), [`ESTYPE_EXCLUDED`](#ESTYPE_EXCLUDED), [`ESTYPE_SUBSCHEMA`](#ESTYPE_SUBSCHEMA) or [`ESTYPE_CONFLICT`](#ESTYPE_CONFLICT).

<a id="COMPILE_OUTSIDE_KEYWORDS"></a>**Rule `COMPILE_OUTSIDE_KEYWORDS`**: MUST

The keywords `estype`, `$schema`, `$vocabulary`, `$id`, `$anchor`, `$dynamicAnchor`, `$defs`, `$comment` and the keywords of the Meta-Data vocabulary ([JSON Schema Validation, section 9](https://json-schema.org/draft/2020-12/json-schema-validation#section-9): `title`, `description`, `default`, `deprecated`, `readOnly`, `writeOnly`, `examples`) MUST stay outside the `oneOf`, in the compiled subschema.

<a id="COMPILE_IDEMPOTENT"></a>**Rule `COMPILE_IDEMPOTENT`**: MUST

Compiling a compiled schema MUST NOT change it.

<a id="COMPILE_DETECT"></a>**Rule `COMPILE_DETECT`**: MUST

A subschema with `estype` T MUST be treated as compiled, and left as it is, when its only keywords are `oneOf` and keywords of [`COMPILE_OUTSIDE_KEYWORDS`](#COMPILE_OUTSIDE_KEYWORDS), and the `oneOf` holds exactly two subschemas: the first equal to the ECSON branch of T, and the second a schema whose only keyword is an `allOf` of a schema and `{ "not": E }`, where E is the ECSON branch of T.

> **Note (non-normative)**
>
> Any other `oneOf` written by the author belongs to the declared schema and moves into the plain branch.

> **Tip (non-normative): Example**
>
> ```json
> { "title": "Created at", "type": "string", "format": "date-time", "estype": "date" }
> ```
> compiles to
> ```json
> {
>   "title": "Created at",
>   "estype": "date",
>   "oneOf": [
>     { "type": "object", "required": ["$date"], "properties": { "$date": true }, "additionalProperties": false },
>     { "allOf": [
>       { "type": "string", "format": "date-time" },
>       { "not": { "type": "object", "required": ["$date"], "properties": { "$date": true }, "additionalProperties": false } }
>     ] }
>   ]
> }
> ```

> **Note (non-normative): Rationale**
>
> In JSON Schema, all keywords of a schema object apply together. Keeping `"type": "string"` beside a `oneOf` would reject the ECSON form, which is an object, so the declared keywords move into the plain branch. A declared schema may accept objects, for example `{ "estype": "bigint", "minimum": 0 }` (validation keywords apply only to their own type) or the default plain schema of `rel`; without the exclusion schema, the ECSON form would match both branches and `oneOf` would reject it. The exclusion keeps the branches disjoint, so `oneOf` matches exactly one. The ECSON branch checks only the shape; the serialized form inside the tag is validated by ECSON ([ECSON `TYPEDEF_VALIDATE`](./ecson.md#TYPEDEF_VALIDATE)).

### 2.1 Default plain schemas

| ES type | Default plain schema |
|---|---|
| `date`, `instant` | `{ "type": "string", "format": "date-time" }` |
| `plaindate` | `{ "type": "string", "format": "date" }` |
| `zoneddatetime`, `plaindatetime`, `plaintime`, `plainyearmonth`, `plainmonthday`, `duration`, `regexp`, `symbol`, `oid`, `numberDecimal` | `{ "type": "string" }` |
| `bigint` | `{ "type": "integer" }` |
| `number` | `{ "type": "number" }` |
| `set`, `map` | `{ "type": "array" }` |
| `bytes`, `binary` | `{ "type": "string", "contentEncoding": "base64" }` |
| `error` | `{ "type": "object", "required": ["name", "message"] }` |
| `timestamp` | `{ "type": "object", "required": ["t", "i"] }` |
| `rel` | `{ "type": ["string", "object", "array"] }` |

> **Note (non-normative)**
>
> These schemas follow the plain JSON forms of ECSON ([ECSON section 5.3](./ecson.md#53-plain-json-form)) of valid values. The plain form `null` (an invalid date, `NaN` and the infinities of `number`, an empty `rel`) is accepted only when the declared schema allows it ([`CONVERT_NULL`](#CONVERT_NULL)).
>
> Formats are used when their syntax matches the plain JSON form of values with a year from 0000 to 9999. Plain forms with an expanded year ([ECSON section 5.3](./ecson.md#53-plain-json-form), for example `+275760-09-13T00:00:00.000Z`) do not match the `date-time` and `date` formats of RFC 3339, so a validator that asserts `format` rejects them. The RFC 3339 `time` format requires a UTC offset, which `Temporal.PlainTime` strings do not have, and the `duration` format forbids signs and fractions, which `Temporal.Duration` strings can have; so these types use no format.
>
> Generic validators treat `format` and `contentEncoding` as annotations by default ([JSON Schema Validation, sections 7.2.1 and 8.1](https://json-schema.org/draft/2020-12/json-schema-validation#section-7.2.1)): a malformed date string or Base64 string passes the compiled schema, and the converter rejects it (for example [ECSON `TYPE_BYTES_VALID`](./ecson.md#TYPE_BYTES_VALID)).

> **Caution (non-normative): References into declared schemas**
>
> Compilation moves the declared schema into the `oneOf`, so a `$ref` with a JSON Pointer into a subschema with `estype` (for example `#/properties/a/items`) no longer resolves after compilation. Use `$defs` or `$anchor` as targets of `$ref`: they stay outside the `oneOf` ([`COMPILE_OUTSIDE_KEYWORDS`](#COMPILE_OUTSIDE_KEYWORDS)).

## 3. Definitions document

The definitions document is a helper: a published schema with one compiled subschema per ES type, which schema authors reference with `$ref` instead of writing `estype` and compiling.

<a id="DEFS_DOCUMENT"></a>**Rule `DEFS_DOCUMENT`**: MUST

The definitions document MUST be a JSON Schema 2020-12 document with `$id` `https://lingodata.dev/estype/defs/0.1` and, in `$defs`, one subschema for each ES type of the table in [section 2.1](#21-default-plain-schemas), named by the ES type and equal to the compilation of `{ "estype": T }`.

<a id="DEFS_EQUIVALENT"></a>**Rule `DEFS_EQUIVALENT`**: MUST

A subschema whose only keywords are a `$ref` to an entry of the definitions document and keywords of [`COMPILE_OUTSIDE_KEYWORDS`](#COMPILE_OUTSIDE_KEYWORDS) MUST be treated as equivalent to the compiled subschema with that `estype`, including for conversion ([section 4](#4-conversion-to-native-values)).

> **Tip (non-normative): Example**
>
> ```json
> { "properties": { "createdAt": { "$ref": "https://lingodata.dev/estype/defs/0.1#/$defs/date" } } }
> ```

> **Caution (non-normative): Keywords next to `$ref`**
>
> All keywords of a schema object apply together, including those next to `$ref`. Adding `"type": "string"` beside a `$ref` to a definition rejects the ECSON form. To narrow the plain form (for example with `minimum`), write `estype` and the declared schema and compile, instead of using `$ref`.

## 4. Conversion to native values

The rules of this section apply to each value whose subschema has `estype`, directly or through `$ref` ([`CONVERT_REF`](#CONVERT_REF)). A converter is an implementation at the Converter level ([section 5.1](#51-conformance)).

<a id="CONVERT_PLAIN_SHOULD"></a>**Rule `CONVERT_PLAIN_SHOULD`**: SHOULD

A library that deserializes plain JSON with a schema, and does not claim the Converter level, SHOULD convert each value whose subschema has `estype` from its plain JSON form to the native value of that ES type.

<a id="CONVERT_ACCEPTED_FORMS"></a>**Rule `CONVERT_ACCEPTED_FORMS`**: MUST

A converter MUST accept, for each ES type, a value without a tag in its plain JSON form ([ECSON section 5.3](./ecson.md#53-plain-json-form)) and a value without a tag in the serialized form that ECSON writes inside the tag. For example, a `bigint` is accepted as `42` and as `"42"`, and a `date` as `"2024-01-15T00:00:00.000Z"` and as `1705276800000`.

> **Note (non-normative)**
>
> A declared schema may thus choose either form, for example `{ "estype": "bigint", "type": "string" }` for big integers sent as strings. The ECSON form, with the tag (`{ "$bigint": "42" }`), is accepted by [`CONVERT_ECSON_WITH_SCHEMA`](#CONVERT_ECSON_WITH_SCHEMA).

<a id="CONVERT_PLAIN_READ"></a>**Rule `CONVERT_PLAIN_READ`**: MUST

A converter MUST read a value without a tag by mapping it to the serialized form of the tag of its ES type, as the inverse of the plain JSON form of [ECSON section 5.3](./ecson.md#53-plain-json-form) (a value already in the serialized form stays as it is), and by deserializing that form by the rules of ECSON. A form that ECSON rejects fails [`CONVERT_FAIL`](#CONVERT_FAIL).

<a id="CONVERT_PLAIN_LOSS"></a>**Rule `CONVERT_PLAIN_LOSS`**: MUST

A converter MUST read the plain JSON form of a `symbol` (a string) as a new symbol with that description, which is not in the global symbol registry; the plain JSON form of `bytes` (a Base64 string) as a `Uint8Array`; and the plain JSON form of `binary` (a Base64 string) with the subtype `00`.

> **Note (non-normative): Forms with loss**
>
> These plain JSON forms do not keep the whole value: a registered symbol, the type of a typed array and the subtype of a `binary` are lost. Clients that need the exact value send the ECSON form.

<a id="CONVERT_NULL"></a>**Rule `CONVERT_NULL`**: MUST

A plain JSON `null` MUST NOT be converted: it stays `null`, and is valid only when the declared schema accepts it. This does not apply to a `null` inside a tag, such as `{ "$date": null }` (an invalid date) or `{ "$rel": null }` (an empty reference), which is converted.

<a id="CONVERT_NESTED"></a>**Rule `CONVERT_NESTED`**: MUST

Subschemas nested in the declared schema MUST be applied to the members of the value after conversion, whether the value arrived in the ECSON form or in the plain JSON form. The declared schema sees a `set` as the array of its members and a `map` as the array of its `[key, value]` pairs, as in their plain JSON forms, so `items` (and, for a `map`, `prefixItems` inside `items`) describes the members in both forms.

> **Note (non-normative)**
>
> The compiled schema alone does not validate the members of the ECSON form: the ECSON branch checks only its shape ([`COMPILE_ECSON_BRANCH`](#COMPILE_ECSON_BRANCH)). Only the converter applies the nested subschemas to them.

> **Tip (non-normative): Example**
>
> With `{ "estype": "map", "type": "array", "items": { "type": "array", "prefixItems": [{ "type": "string" }, { "estype": "date" }] } }`, both `[["a", "2024-01-15T00:00:00.000Z"]]` and `{ "$map": [["a", "2024-01-15T00:00:00.000Z"]] }` give a `Map` whose value for `a` is a `Date`.

<a id="CONVERT_ECSON_WITH_SCHEMA"></a>**Rule `CONVERT_ECSON_WITH_SCHEMA`**: MUST

A converter MUST, when deserializing with a schema, produce the native value of each value whose subschema has `estype`, whether the value is in the ECSON form or in the plain JSON form.

<a id="CONVERT_REF"></a>**Rule `CONVERT_REF`**: MUST

A value whose subschema reaches a subschema with `estype` through `$ref` MUST be converted as for that subschema. A `$ref` to an entry of the definitions document follows [`DEFS_EQUIVALENT`](#DEFS_EQUIVALENT).

<a id="CONVERT_FAIL"></a>**Rule `CONVERT_FAIL`**: MUST

A value whose subschema has `estype` T, that is not in the ECSON form of T and cannot be converted to T, MUST be reported as not valid against the schema, with the path of the value.

<a id="CONVERT_PATH_POINTER"></a>**Rule `CONVERT_PATH_POINTER`**: SHOULD

The path of a value in a report of [`CONVERT_FAIL`](#CONVERT_FAIL) or [`CONVERT_MALFORMED_ECSON`](#CONVERT_MALFORMED_ECSON) SHOULD be a JSON Pointer ([RFC 6901](https://www.rfc-editor.org/rfc/rfc6901)).

<a id="CONVERT_FORM_PER_FIELD"></a>**Rule `CONVERT_FORM_PER_FIELD`**: MUST

A converter MUST determine the form of each value (ECSON form or plain JSON form) independently of the other values of the document.

> **Note (non-normative)**
>
> A document may thus mix both forms. The rest of the document, outside the values whose subschema has `estype`, is read by the rules of the format of the text: in an ECSON text, keys of plain objects are escaped ([ECSON `ESCAPE_DESERIALIZE`](./ecson.md#ESCAPE_DESERIALIZE)); in a plain JSON text, keys starting with `$` are plain keys ([ECSON `PLAIN_FORM_READ`](./ecson.md#PLAIN_FORM_READ)).

<a id="CONVERT_MALFORMED_ECSON"></a>**Rule `CONVERT_MALFORMED_ECSON`**: MUST

A value in the ECSON form of its ES type whose serialized form is malformed MUST be reported as not valid against the schema, as a failure of the ECSON rule [`TYPEDEF_VALIDATE`](./ecson.md#TYPEDEF_VALIDATE), with the path of the value.

<a id="CONVERT_MALFORMED_DETAIL"></a>**Rule `CONVERT_MALFORMED_DETAIL`**: MAY

A converter MAY add the path inside the serialized form to the report of [`CONVERT_MALFORMED_ECSON`](#CONVERT_MALFORMED_ECSON), as extra information.

> **Tip (non-normative): Example**
>
> With a schema where `createdAt` and `paidAt` have `estype: date`, the document `{ "createdAt": { "$date": "2026-11-27T10:00:00.000Z" }, "paidAt": "2026-11-27T11:00:00.000Z" }` is valid and gives two `Date` values. `{ "createdAt": { "$date": "yesterday" } }` fails [`TYPEDEF_VALIDATE`](./ecson.md#TYPEDEF_VALIDATE) at `/createdAt`. `{ "createdAt": { "$bigint": "1" } }` is not the ECSON form of `date` and fails [`CONVERT_FAIL`](#CONVERT_FAIL) at `/createdAt`.

> **Tip (non-normative): Example**
>
> With the schema `{ "properties": { "total": { "estype": "bigint" } } }`, both `{ "total": 42 }` and `{ "total": { "$bigint": "42" } }` deserialize to `{ total: 42n }`.

## 5. Conformance and references

### 5.1 Conformance

| Level | Requirements |
|---|---|
| **Compiler** | Sections 1, 2 and 3: validates `estype` values, compiles schemas and recognizes references to the definitions document ([`DEFS_EQUIVALENT`](#DEFS_EQUIVALENT)) |
| **Converter** | Compiler, plus [section 4](#4-conversion-to-native-values) |

<a id="CONFORMANCE_DECLARE"></a>**Rule `CONFORMANCE_DECLARE`**: MUST

An implementation MUST state which conformance level it meets and which ES types it supports.

<a id="CONFORMANCE_UNSUPPORTED"></a>**Rule `CONFORMANCE_UNSUPPORTED`**: MUST

An implementation MUST fail, and MUST NOT ignore `estype`, for a schema or value with an ES type that it does not support.

### 5.2 Normative references

- [RFC 2119](https://www.rfc-editor.org/rfc/rfc2119) and [RFC 8174](https://www.rfc-editor.org/rfc/rfc8174): requirement level key words (BCP 14)
- [JSON Schema 2020-12: Core](https://json-schema.org/draft/2020-12/json-schema-core) and [Validation](https://json-schema.org/draft/2020-12/json-schema-validation)
- [RFC 3339](https://www.rfc-editor.org/rfc/rfc3339): date and time formats (`date-time`, `date`, `time`, `duration`)
- [RFC 6901](https://www.rfc-editor.org/rfc/rfc6901): JSON Pointer
- [ECSON](https://github.com/lingodata/ecson) `0.2.x`: tags, type sets, plain JSON form ([ECSON section 5.3](./ecson.md#53-plain-json-form)) and tag namespaces ([ECSON section 6](./ecson.md#6-tag-ownership-and-namespaces))
- [Semantic Versioning 2.0.0](https://semver.org/)

### 5.3 Informative references

- [Ajv](https://ajv.js.org/): custom keywords, strict mode and schema compilation ([section 2](#2-compilation))
- [Protocol Buffers `jstype`](https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/descriptor.proto): a field option with a similar name and a different meaning (how 64-bit integers map to JavaScript numbers or strings)
