svelte-forms-lib icon indicating copy to clipboard operation
svelte-forms-lib copied to clipboard

Move filed validation to validateField

Open sedx opened this issue 5 years ago • 1 comments

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

sedx avatar Mar 29 '20 16:03 sedx

Hello,

Is there a way to merge or close this PR ? Is there still some devs here ?

rccc avatar Jan 19 '21 10:01 rccc