modular-forms icon indicating copy to clipboard operation
modular-forms copied to clipboard

custom validation doesnt work on submit

Open rylofu opened this issue 6 months ago • 2 comments

I have a delivery form with a flat field and a noFlat checkbox. When the form is submitted, I need to check that if noFlat is not checked, then flat is required. I have a simple function to check this

const validateFlatRequired = (value: Maybe<FieldValue>): MaybePromise<boolean> => {
        const noFlatValue = getValue(DeliveryFormStore, "noFlat")
        if (!value) {
            return noFlatValue === true
        }
        return true
    }

but it only works on input (verified using console.log inside it). Is this expected behavior?

rylofu avatar Jun 09 '25 03:06 rylofu

Can you provided a minimal reproduction via StackBlitz?

fabian-hiller avatar Jun 11 '25 01:06 fabian-hiller

yeah, here's my code https://stackblitz.com/edit/github-k7kd32zi?file=src%2FApp.tsx The checkFlatFilled function call does not occur on submit

rylofu avatar Jun 11 '25 03:06 rylofu