Skip to content

object

@tsed/schema

Usage

typescript
import { object } from "@tsed/schema";

See /packages/specs/schema/src/fn/object.ts.

Overview

ts
function object<P extends Record<string, JsonSchema<any>> = Record<string, JsonSchema<any>>>(properties?: P): JsonSchema<import("../index.js").PropsToShape<P>>;
  • properties (P): Optional. - An object containing property definitions where each value is a JsonSchema

Description

Declare a new object model.

See JsonSchema to discover available methods.

Example

typescript
const userSchema = object({
  name: string(),
  age: number()
});

Released under the MIT License.