2024-06-12 22:05:19 +00:00
|
|
|
<template>
|
|
|
|
<DocSectionText v-bind="$attrs">
|
|
|
|
<p>Validation errors in a form are displayed with the <i>error</i> severity.</p>
|
|
|
|
</DocSectionText>
|
2024-10-26 14:23:18 +00:00
|
|
|
<div class="card flex justify-center">
|
|
|
|
<div class="flex flex-col gap-4">
|
2024-10-28 21:22:08 +00:00
|
|
|
<Message v-if="!username || !email" severity="error" icon="pi pi-times-circle" class="mb-2">Validation error</Message>
|
|
|
|
<Message v-if="username && email" severity="success" icon="pi pi-times-circle" class="mb-2">Form is valid</Message>
|
|
|
|
<div class="flex flex-col gap-1">
|
|
|
|
<InputText v-model="username" placeholder="Username" aria-label="username" :invalid="!username" />
|
|
|
|
<Message v-if="!username" severity="error" variant="simple" size="small">Username is required</Message>
|
2024-10-26 14:23:18 +00:00
|
|
|
</div>
|
2024-10-28 21:22:08 +00:00
|
|
|
<div class="flex flex-col gap-1">
|
|
|
|
<InputText v-model="email" placeholder="Email" aria-label="email" :invalid="!email" />
|
|
|
|
<Message v-if="!email" severity="error" variant="simple" size="small">Email is not valid</Message>
|
2024-10-26 14:23:18 +00:00
|
|
|
</div>
|
2024-06-12 22:05:19 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<DocSectionCode :code="code" />
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
2024-10-28 21:22:08 +00:00
|
|
|
username: null,
|
|
|
|
email: null,
|
2024-06-12 22:05:19 +00:00
|
|
|
code: {
|
|
|
|
basic: `
|
2024-10-28 21:22:08 +00:00
|
|
|
<Message v-if="!username || !email" severity="error" icon="pi pi-times-circle" class="mb-2">Validation error</Message>
|
|
|
|
<Message v-if="username && email" severity="success" icon="pi pi-times-circle" class="mb-2">Form is valid</Message>
|
|
|
|
<div class="flex flex-col gap-1">
|
|
|
|
<InputText v-model="username" placeholder="Username" aria-label="username" :invalid="!username" />
|
|
|
|
<Message v-if="!username" severity="error" variant="simple" size="small">Username is required</Message>
|
|
|
|
</div>
|
|
|
|
<div class="flex flex-col gap-1">
|
|
|
|
<InputText v-model="email" placeholder="Email" aria-label="email" :invalid="!email" />
|
|
|
|
<Message v-if="!email" severity="error" variant="simple" size="small">Email is not valid</Message>
|
2024-06-12 22:05:19 +00:00
|
|
|
</div>
|
|
|
|
`,
|
|
|
|
options: `
|
|
|
|
<template>
|
2024-10-28 21:22:08 +00:00
|
|
|
<div class="flex flex-col gap-4">
|
|
|
|
<Message v-if="!username || !email" severity="error" icon="pi pi-times-circle" class="mb-2">Validation error</Message>
|
|
|
|
<Message v-if="username && email" severity="success" icon="pi pi-times-circle" class="mb-2">Form is valid</Message>
|
|
|
|
<div class="flex flex-col gap-1">
|
|
|
|
<InputText v-model="username" placeholder="Username" aria-label="username" :invalid="!username" />
|
|
|
|
<Message v-if="!username" severity="error" variant="simple" size="small">Username is required</Message>
|
|
|
|
</div>
|
|
|
|
<div class="flex flex-col gap-1">
|
|
|
|
<InputText v-model="email" placeholder="Email" aria-label="email" :invalid="!email" />
|
|
|
|
<Message v-if="!email" severity="error" variant="simple" size="small">Email is not valid</Message>
|
2024-06-12 22:05:19 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
<\/script>
|
|
|
|
`,
|
|
|
|
composition: `
|
|
|
|
<template>
|
2024-10-28 21:22:08 +00:00
|
|
|
<div class="flex flex-col gap-4">
|
|
|
|
<Message v-if="!username || !email" severity="error" icon="pi pi-times-circle" class="mb-2">Validation error</Message>
|
|
|
|
<Message v-if="username && email" severity="success" icon="pi pi-times-circle" class="mb-2">Form is valid</Message>
|
|
|
|
<div class="flex flex-col gap-1">
|
|
|
|
<InputText v-model="username" placeholder="Username" aria-label="username" :invalid="!username" />
|
|
|
|
<Message v-if="!username" severity="error" variant="simple" size="small">Username is required</Message>
|
|
|
|
</div>
|
|
|
|
<div class="flex flex-col gap-1">
|
|
|
|
<InputText v-model="email" placeholder="Email" aria-label="email" :invalid="!email" />
|
|
|
|
<Message v-if="!email" severity="error" variant="simple" size="small">Email is not valid</Message>
|
2024-06-12 22:05:19 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
<\/script>
|
|
|
|
`
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|