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