API reference@evolu/commonType › partial

function partial<Props>(
  props: Props,
): ObjectType<{ [K in string | number | symbol]: OptionalType<Props[K]> }>;

Defined in: packages/common/src/Type.ts:4404

Creates a partial object type where all properties are optional.

This is useful when we want to validate an object in which none of the keys are required, but if they are present they must conform to their corresponding Types.

Example

const PartialUser = partial({
  name: NonEmptyString,
  age: PositiveNumber,
});

// Valid: an empty object is accepted
PartialUser.from({});

// Valid: when provided, the properties must validate correctly
PartialUser.from({ name: "Alice" });

// Invalid: if a property is present but fails validation it returns an error
PartialUser.from({ age: -5 });