#Form issue

1 messages · Page 1 of 1 (latest)

polar parrot
#

Alll the errors are removed if I change a single value, how to prevent it.

const courseForm = useForm({
initialValues: {
isSaveClickedAtleastOnce: false,
loading: -1,
step: 1,
cta: 'Buy Now',
},
validateInputOnChange: true,
validate: values => ({
title: !values?.title
? 'Title is required'
: values.title?.length > 100
? 'Title should be less than 100 characters'
: null,

  price: !values?.price
      ? 'Price is required'
      : values.price < 1
        ? 'Price should be greater than 0'
        : null,
  discountedPrice: !values?.discountedPrice
      ? 'Discounted Price is required'
      : values.discountedPrice >= values.price
        ? 'Discounted Price should be less than price'
        : values.discountedPrice < 0
          ? 'Discounted Price should be greater than 0'
          : null,

});

willow torrent
#

Provide a sandbox with a minimal reproduction.

polar parrot
#

@willow torrent does validate run for every every valiable if a single value changes?

#

Like if the price change the validate will run for title , description?

willow torrent
#

I do not remember the exact logic, you can browse the source code to learn implementation details