cerulea/lexicon

define atproto schemas in TypeScript

git clone https://git.t4t.associates/cerulea/lexicon

Charlotte Somvalidation: a Location carries the path and issues25f2629

main
470 B9 linesraw
1import type { Field, Schema } from "../schema.ts";
2
3// A field's schema with its optional and nullable wrappers peeled off.
4export function unwrap(field: Field): { schema: Schema; optional: boolean; nullable: boolean } {
5  const optional = field.type === "optional";
6  const inner = field.type === "optional" ? field.inner : field;
7  const nullable = inner.type === "nullable";
8  return { schema: inner.type === "nullable" ? inner.inner : inner, optional, nullable };
9}