Config parsing helpers: JSONC parsing with rich error reporting, plus validation of parsed data against both zod and Effect schemas.
Methods
(static) effectSchema(schema, data, source) → {*}
Validate and decode data against an Effect schema, preserving the user's original property order and rejecting unrecognized top-level keys.
| Name | Type | Description |
|---|---|---|
schema | Object | An Effect schema to decode against. |
data | * | The data to validate and decode. |
source | string | Path/source label attached to validation errors. |
When unknown top-level keys are present or decoding fails.
- Type
- InvalidError
The decoded value.
- Type:
- *
(static) jsonc(text, filepath) → {*}
Parse JSONC (JSON with comments and trailing commas) text into a value. On parse failure, throws a JsonError whose message includes the input and a per-error report with line/column and a caret pointing at the problem.
| Name | Type | Description |
|---|---|---|
text | string | The JSONC source text. |
filepath | string | Path used to label errors (the source of the text). |
When the text contains JSONC syntax errors.
- Type
- JsonError
The parsed value.
- Type:
- *
(static) schema(schema, data, source) → {*}
Validate and parse data against a zod schema.
| Name | Type | Description |
|---|---|---|
schema | Object | A zod schema exposing |
data | * | The data to validate. |
source | string | Path/source label attached to validation errors. |
When validation fails, carrying the zod issues.
- Type
- InvalidError
The parsed (validated) data.
- Type:
- *
(inner) topLevelExtraKeys(schema, data) → {Array.<string>}
List top-level keys present in data that are not declared by the schema. Returns an empty array unless data is a plain object and the schema is a closed object type (no index signatures), since only then are extra keys meaningful.
| Name | Type | Description |
|---|---|---|
schema | Object | An Effect schema whose AST is inspected. |
data | * | The data whose keys are checked. |
The unrecognized top-level key names.
- Type:
- Array.<string>