1.1.0 • Published 2 years ago

@inlang/json-types v1.1.0

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
2 years ago

JSON types that are used across inlang's codebase (and hopefully useful to external developers as well!).

Usage

As type

Importing any JSONObject as type will prune runtime validation code.

import type { JSONObject } from "@inlang/json-types"

type MyType = JSONObject<{
	foo: string
	bar: number
}>

Validation

Every JSONObject is defined as JSONSchema with typebox and can be used for validation

import { JSONObject } from "@inlang/json-types"

const isValid = someJsonSchemaValidator(
	JSONObject({
		foo: string(),
		bar: number(),
	}),
)