Skip to content

1.3.1

Compare
Choose a tag to compare
@pedro-lb pedro-lb released this 01 Jul 16:08
· 178 commits to master since this release

🔥 Automatic mapping of initialTouched according to initialValues

Formup will now automatically map initialTouched object according to what you pass to initialValues.

These are the possible outcomes:

  • If you pass initialValues to useFormup's options, formup will map initialTouched according to the fields that were passed.

Example:

useFormup(schema, {
  initialValues: {
    id: 100,
    personalInformation: {
      name: "Foo",
      surname: "Bar",
    },
  },
});

// Formup will map initialTouched to:
{
  id: true,
  personalInformation: {
    name: true,
    surname: true,
  },
}
  • If you pass initialTouched to useFormup's options, formup will not map anything and will use the value you provided instead.

Example:

useFormup(schema, {
  initialValues: {
    id: 100,
    personalInformation: {
      name: "Foo",
      surname: "Bar",
    },
  },
  initialTouched: {
    id: true,
  },
});

// Formup will map initialTouched to:
{
  id: true,
}