API reference@evolu/commonlocal‑first/Schema › testEvoluSchema

const testEvoluSchema: {
  project: {
    id: TableId<"Project">;
    name: BrandType<
      BrandType<
        BrandType<
          Type<
            "String",
            string,
            string,
            TypeOfError<"String">,
            null,
            TypeOfError<"String">,
            never,
            string,
            true
          >,
          "Trimmed",
          TrimmedError
        >,
        "MinLength1",
        MinLengthError<1>
      >,
      "MaxLength100",
      MaxLengthError<100>
    >;
  };
  todo: {
    id: TableId<"Todo">;
    isCompleted: UnionType<
      readonly [
        UnionType<readonly [LiteralType<0>, LiteralType<1>]>,
        LiteralType<null>,
      ]
    >;
    projectId: UnionType<readonly [TableId<"Project">, LiteralType<null>]>;
    title: BrandType<
      BrandType<
        BrandType<
          Type<
            "String",
            string,
            string,
            TypeOfError<"String">,
            null,
            TypeOfError<"String">,
            never,
            string,
            true
          >,
          "Trimmed",
          TrimmedError
        >,
        "MinLength1",
        MinLengthError<1>
      >,
      "MaxLength100",
      MaxLengthError<100>
    >;
  };
};

Defined in: packages/common/src/local-first/Schema.ts:211

Todo and project schema for tests and examples. A todo can belong to a project or have no project. Use an explicit schema when teaching schema definition.

Example

import {
  assertOk,
  testEvoluSchema,
  testProjectId,
  testTodoId,
} from "@evolu/common";

assertOk(testEvoluSchema.todo.id.from(testTodoId), testTodoId);
assertOk(testEvoluSchema.todo.projectId.from(testProjectId), testProjectId);

Type Declaration

NameTypeDefault valueDefined in
project{ id: TableId<"Project">; name: BrandType<BrandType<BrandType<Type<"String", string, string, TypeOfError<"String">, null, TypeOfError<"String">, never, string, true>, "Trimmed", TrimmedError>, "MinLength1", MinLengthError<1>>, "MaxLength100", MaxLengthError<100>>; }-packages/common/src/local-first/Schema.ts:218
project.idTableId<"Project">TestProjectIdpackages/common/src/local-first/Schema.ts:219
project.nameBrandType<BrandType<BrandType<Type<"String", string, string, TypeOfError<"String">, null, TypeOfError<"String">, never, string, true>, "Trimmed", TrimmedError>, "MinLength1", MinLengthError<1>>, "MaxLength100", MaxLengthError<100>>NonEmptyTrimmedString100packages/common/src/local-first/Schema.ts:220
todo{ id: TableId<"Todo">; isCompleted: UnionType<readonly [UnionType<readonly [LiteralType<0>, LiteralType<1>]>, LiteralType<null>]>; projectId: UnionType<readonly [TableId<"Project">, LiteralType<null>]>; title: BrandType<BrandType<BrandType<Type<"String", string, string, TypeOfError<"String">, null, TypeOfError<"String">, never, string, true>, "Trimmed", TrimmedError>, "MinLength1", MinLengthError<1>>, "MaxLength100", MaxLengthError<100>>; }-packages/common/src/local-first/Schema.ts:212
todo.idTableId<"Todo">TestTodoIdpackages/common/src/local-first/Schema.ts:213
todo.isCompletedUnionType<readonly [UnionType<readonly [LiteralType<0>, LiteralType<1>]>, LiteralType<null>]>-packages/common/src/local-first/Schema.ts:215
todo.projectIdUnionType<readonly [TableId<"Project">, LiteralType<null>]>-packages/common/src/local-first/Schema.ts:216
todo.titleBrandType<BrandType<BrandType<Type<"String", string, string, TypeOfError<"String">, null, TypeOfError<"String">, never, string, true>, "Trimmed", TrimmedError>, "MinLength1", MinLengthError<1>>, "MaxLength100", MaxLengthError<100>>NonEmptyTrimmedString100packages/common/src/local-first/Schema.ts:214