Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions ark/docs/content/docs/ecosystem/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,28 @@ export default defineConfig({
```

> For more details, see the [Getting Started guide](https://use-drzl.github.io/drzl/guide/getting-started.html).

### shorn

[shorn](https://shorn.dev) turns an ArkType type into compact binary serialization. Field names and type tags stay out of the payload because the type already provides them, so there is no schema language to learn and nothing to generate.

ArkType 2.1.28 and newer implements both [Standard Schema](https://standardschema.dev/schema) and [Standard JSON Schema](https://standardschema.dev/json-schema), so a type can be passed straight to `encode`. Validation runs on encode and again on decode.

```ts
// @noErrors
import { type } from "arktype"
import { decode, encode } from "@chichurita/shorn"

const Person = type({
name: "string",
age: "number.integer >= 0",
sex: "'M' | 'F' | 'X'"
})

const bytes = encode(Person, { name: "Grace", age: 45, sex: "F" })
bytes.length // 8, where the same record is 35 bytes of minified JSON

decode(Person, bytes) // typed and validated
```

> ArkType objects are open by default, so shorn rejects undeclared properties during encoding rather than dropping data. Use `"+": "delete"` to strip expected extras. See the [ArkType guide](https://shorn.dev/validators/arktype/) for the details.
2 changes: 1 addition & 1 deletion ark/docs/content/docs/ecosystem/meta.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"title": "Ecosystem",
"icon": "New",
"pages": ["[ArkEnv](/docs/ecosystem#arkenv)", "[DRZL](/docs/ecosystem#drzl)"]
"pages": ["[ArkEnv](/docs/ecosystem#arkenv)", "[DRZL](/docs/ecosystem#drzl)", "[shorn](/docs/ecosystem#shorn)"]
}
Loading