chainlist / svelte-forms

Svelte forms validation made easy
MIT License
401 stars 36 forks source link

[REQUEST] eitherOr validator #90

Open andrejohansson opened 1 year ago

andrejohansson commented 1 year ago

Is your feature request related to a problem? Please describe. I would like to se a variant of the combined function that is "either field A or B should be valid"

Describe alternatives you've considered Tried combining a hidden field and setting required on the combined field, and it works if all validation you need for the fields are "they exist" but not if you need any other validation per field:

const emailOrPhone = combined('emailOrPhone', [email, phone], ([email, phone]) => [email.value, phone.value].join(' '), [required()]); 

Additional context Example: I would like either an email or a phone number to exist and be valid.