Dev Helpers
← Back

Build a field-error map

Build a field-error map using TypeScript.

Open this example in the interactive library

Source code

type Fields = { name: string; age: number; subscribed: boolean };
const initial: Fields = { name: "Ada", age: 30, subscribed: false };
console.log({ age: "Must be at least 18" } satisfies Partial<
  Record<keyof Fields, string>
>);

Sample output

{ age: 'Must be at least 18' }