svelte-forms-lib
svelte-forms-lib copied to clipboard
Move filed validation to validateField
Motivation
I have some custom Input. It's accept mask to format value and export value. DOM input element has masked value, but component export already unmasked value.
When I create form, I can't use handleChange, because form will store masked value, so I used bind:value={$form.phone}. To track touched state I add custom blur event handler, where call updateTouched. The last action that I should do to make my form works is validate field value and set errors.
Example of my form: https://codesandbox.io/s/boring-bash-cnv3x
Solution
I moved code that validate field value to new validateField function. Update handleChange to call it. Also add validateField to return of createForm
Hello,
Is there a way to merge or close this PR ? Is there still some devs here ?