Skip to main content

$object

Callable

  • $object<Shape>(properties: ObjectShape<Shape>, options?: SchemaOptions<ObjectOptions, NoInfer<{ [ KeyType in string | number | symbol ]: Omit<{ [ K in string | number | symbol ]: Shape[K][infer] }, keyof UndefinedToOptional<{ [ K in string | number | symbol ]: ...[...][infer] }>> & UndefinedToOptional<{ [ K in string | number | symbol ]: Shape[K][infer] }>[KeyType] }>>): ObjectType<Shape>

  • Create a new ObjectType instance with the given options.

    Example

    $object({
    foo: $string
    bar: $integer
    })

    Type parameters

    • Shape: Record<string, Node>

    Parameters

    • properties: ObjectShape<Shape>

      Key value pairs that define the object.

    • options: SchemaOptions<ObjectOptions, NoInfer<{ [ KeyType in string | number | symbol ]: Omit<{ [ K in string | number | symbol ]: Shape[K][infer] }, keyof UndefinedToOptional<{ [ K in string | number | symbol ]: ...[...][infer] }>> & UndefinedToOptional<{ [ K in string | number | symbol ]: Shape[K][infer] }>[KeyType] }>> = {}

      Additional options to pass to the number.

    Returns ObjectType<Shape>