Reduce min name length
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
import { parseError } from '#shared/utils/error';
|
import { parseError } from '#shared/utils/error';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
const validation = useValidation();
|
||||||
const emits = defineEmits<{
|
const emits = defineEmits<{
|
||||||
update: [];
|
update: [];
|
||||||
}>();
|
}>();
|
||||||
@@ -47,6 +48,7 @@ async function submit() {
|
|||||||
}
|
}
|
||||||
pending.value = false;
|
pending.value = false;
|
||||||
}
|
}
|
||||||
|
// TODO: translate
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -56,13 +58,29 @@ async function submit() {
|
|||||||
<VaModal v-model="isOpen" close-button hide-default-actions>
|
<VaModal v-model="isOpen" close-button hide-default-actions>
|
||||||
<h3 class="text-3xl">Create a new team</h3>
|
<h3 class="text-3xl">Create a new team</h3>
|
||||||
<div class="mt-4 flex flex-col gap-4">
|
<div class="mt-4 flex flex-col gap-4">
|
||||||
<VaInput v-model="data.name" label="Name" placeholder="My cool team" />
|
<VaInput
|
||||||
|
v-model="data.name"
|
||||||
|
label="Name"
|
||||||
|
placeholder="My cool team"
|
||||||
|
min-length="3"
|
||||||
|
max-length="256"
|
||||||
|
counter
|
||||||
|
:rules="[
|
||||||
|
validation.required('Name'),
|
||||||
|
validation.max('Name', 256),
|
||||||
|
validation.min('Name', 3)
|
||||||
|
]"
|
||||||
|
required
|
||||||
|
/>
|
||||||
<VaTextarea
|
<VaTextarea
|
||||||
v-model="data.description"
|
v-model="data.description"
|
||||||
max-rows="4"
|
max-rows="4"
|
||||||
min-rows="2"
|
min-rows="2"
|
||||||
label="Description"
|
label="Description"
|
||||||
placeholder="The best team!"
|
placeholder="The best team!"
|
||||||
|
max-length="256"
|
||||||
|
counter
|
||||||
|
:rules="[validation.maxOptional('Description', 256)]"
|
||||||
/>
|
/>
|
||||||
<p>An invite code will be generated automatically.</p>
|
<p>An invite code will be generated automatically.</p>
|
||||||
<VaAlert v-if="error" color="danger">{{ t(error) }}</VaAlert>
|
<VaAlert v-if="error" color="danger">{{ t(error) }}</VaAlert>
|
||||||
|
|||||||
@@ -23,6 +23,13 @@ export default function () {
|
|||||||
(value && value.length <= max) ||
|
(value && value.length <= max) ||
|
||||||
t('validation.max_length', { name, max });
|
t('validation.max_length', { name, max });
|
||||||
},
|
},
|
||||||
|
maxOptional(name: string, max = 64) {
|
||||||
|
return (value: string) =>
|
||||||
|
!value ||
|
||||||
|
value.length <= 0 ||
|
||||||
|
value.length <= max ||
|
||||||
|
t('validation.max_length', { name, max });
|
||||||
|
},
|
||||||
min(name: string, min = 8) {
|
min(name: string, min = 8) {
|
||||||
return (value: string) =>
|
return (value: string) =>
|
||||||
(value && value.length >= min) ||
|
(value && value.length >= min) ||
|
||||||
|
|||||||
@@ -74,11 +74,11 @@ async function submit() {
|
|||||||
:label="t('auth.name')"
|
:label="t('auth.name')"
|
||||||
:placeholder="t('auth.name')"
|
:placeholder="t('auth.name')"
|
||||||
max-length="64"
|
max-length="64"
|
||||||
min-length="5"
|
min-length="1"
|
||||||
:rules="[
|
:rules="[
|
||||||
validation.required(t('auth.name')),
|
validation.required(t('auth.name')),
|
||||||
validation.max(t('auth.name'), 64),
|
validation.max(t('auth.name'), 64),
|
||||||
validation.min(t('auth.name'), 5)
|
validation.min(t('auth.name'), 1)
|
||||||
]"
|
]"
|
||||||
required
|
required
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export default defineEventHandler(async (event) => {
|
|||||||
z.object({
|
z.object({
|
||||||
email: z.email().min(5).trim(),
|
email: z.email().min(5).trim(),
|
||||||
password: z.string().min(8),
|
password: z.string().min(8),
|
||||||
name: z.string().min(5).max(64).trim()
|
name: z.string().min(1).max(64).trim()
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user