Skip to content

Commit

Permalink
validate address input on blur
Browse files Browse the repository at this point in the history
  • Loading branch information
gsteenkamp89 committed Apr 8, 2024
1 parent ffad9c6 commit 104f0d2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/plugins/oSnap/components/Input/Address.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const props = defineProps<{
error?: string;
disabled?: boolean;
}>();
const emit = defineEmits<{
'update:modelValue': [value: string];
}>();
Expand All @@ -24,6 +25,7 @@ const validate = () => {
error.value = 'Address is required';
return;
}
if (!mustBeEthereumAddress(input.value)) {
error.value = 'Invalid address';
return;
Expand All @@ -49,6 +51,11 @@ onMounted(() => {
const handleInput = () => {
emit('update:modelValue', input.value);
};
const handleBlur = () => {
dirty.value = true;
validate();
};
</script>

<template>
Expand All @@ -57,7 +64,7 @@ const handleInput = () => {
:disabled="disabled"
:error="props.error ?? (error || '')"
@input="handleInput()"
@blur="dirty = true"
@blur="handleBlur"
>
<template v-if="label" #label>{{ label }}</template>
</UiInput>
Expand Down

0 comments on commit 104f0d2

Please sign in to comment.