Skip to content

@pcvl/schema / ObjectInput

Type Alias: ObjectInput<Shape> ​

ts
type ObjectInput<Shape> = ComposeObject<{ [Key in keyof Shape]: InferInput<Shape[Key]> }>;

Defined in: schemas/objectInterpretedSchema.ts:62

The object type a value must match going in, composed from each field schema's own input type. A field whose schema is .optional() becomes an optional key.

It is the same in every unknown-key mode: extra keys are a property of the value handed in, not of what the schema asks for, and .strict() rejects them at runtime rather than at the type level.

Type Parameters ​

Shape ​

Shape extends ObjectShape

Example ​

ts
import { pvl, type ObjectInput } from '@pcvl/schema';

const shape = { name: pvl.string(), nickname: pvl.string().optional() };

const input: ObjectInput<typeof shape> = { name: 'Ada' }; // nickname is optional
pvl.object(shape).validate(input);