fix: parent telephone validation

This commit is contained in:
Sebastian Pravda 2023-02-02 18:34:33 +01:00 committed by EETagent
parent c8ced5f79d
commit 911a5f6ee2

View file

@ -185,12 +185,7 @@
} }
return _val !== ''; return _val !== '';
}), }),
telephone: yup.string().test((_val, context) => { telephone: yup.string()
if (context.path.includes('parents[1]') && _val === '') {
return true;
}
return _val?.match(/^\+\d{1,3} \d{3} \d{3} \d{3}$/) !== null;
})
}) })
) )
}); });
@ -222,6 +217,9 @@
}; };
const onSubmit = async (values: CandidateData) => { const onSubmit = async (values: CandidateData) => {
console.log("submit button clicked");
console.log(pagesFilled.map((_, i) => !isPageInvalid(i)));
if (pageIndex === 3) { if (pageIndex === 3) {
if (values.candidate.citizenship === 'Česká republika') { if (values.candidate.citizenship === 'Česká republika') {
if ( if (
@ -297,7 +295,6 @@
onSubmit: async (values: CandidateData) => onSubmit(values) onSubmit: async (values: CandidateData) => onSubmit(values)
}); });
$: console.log($componentErrors['candidate']['telephone'])
const isPageInvalid = (index: number): boolean => { const isPageInvalid = (index: number): boolean => {
switch (index) { switch (index) {
case 0: case 0:
@ -541,7 +538,7 @@
placeholder={$LL.input.email()} placeholder={$LL.input.email()}
/> />
</span> </span>
<span class="w-[50%]"> <span class="w-[50%] ml-2">
<TextField <TextField
error={$typedErrors['candidate']['city']} error={$typedErrors['candidate']['city']}
bind:value={$form.candidate.city} bind:value={$form.candidate.city}
@ -763,6 +760,7 @@
<Submit <Submit
on:click={async (e) => { on:click={async (e) => {
await handleSubmit(e); await handleSubmit(e);
console.log(pagesFilled.map((_, i) => !isPageInvalid(i)));
if (isPageInvalid(pageIndex)) return; if (isPageInvalid(pageIndex)) return;
if (pageIndex === pageCount) { if (pageIndex === pageCount) {
} else { } else {