2020-10-18 18:28:37 +03:00
|
|
|
<template>
|
|
|
|
<FormularioForm v-model="values">
|
|
|
|
<FormularioInput
|
|
|
|
v-slot="{ context }"
|
2020-10-18 20:11:20 +03:00
|
|
|
:validation-messages="{
|
|
|
|
number: 'The value is not a number',
|
|
|
|
required: 'Value required',
|
|
|
|
}"
|
|
|
|
class="mb-3"
|
|
|
|
name="number"
|
2020-10-27 17:29:19 +03:00
|
|
|
validation="required"
|
2020-10-18 18:28:37 +03:00
|
|
|
>
|
2020-10-27 17:29:19 +03:00
|
|
|
<label for="text-field">Text field (required)</label>
|
2020-10-18 20:11:20 +03:00
|
|
|
<input
|
|
|
|
id="text-field"
|
|
|
|
v-model="context.model"
|
|
|
|
type="text"
|
|
|
|
class="form-control"
|
|
|
|
style="max-width: 250px;"
|
2020-10-27 17:29:19 +03:00
|
|
|
@blur="context.runValidation()"
|
2020-10-18 20:11:20 +03:00
|
|
|
>
|
|
|
|
|
|
|
|
<div
|
2020-10-26 17:00:18 +03:00
|
|
|
v-for="(error, index) in context.allErrors"
|
2020-10-18 20:11:20 +03:00
|
|
|
:key="index"
|
|
|
|
class="text-danger"
|
|
|
|
>
|
2020-10-27 17:29:19 +03:00
|
|
|
{{ error }}
|
2020-10-18 18:28:37 +03:00
|
|
|
</div>
|
2020-10-18 20:11:20 +03:00
|
|
|
</FormularioInput>
|
|
|
|
|
|
|
|
<FormularioInput
|
|
|
|
v-slot="{ context }"
|
|
|
|
:validation-messages="{ in: 'The value is not in range (abc,def)' }"
|
|
|
|
class="mb-3"
|
|
|
|
name="abcdef-field"
|
|
|
|
validation="in:abc,def"
|
|
|
|
>
|
|
|
|
<label for="abcdef-field">Text field (in:abc,def)</label>
|
|
|
|
<input
|
|
|
|
id="abcdef-field"
|
|
|
|
v-model="context.model"
|
|
|
|
type="text"
|
|
|
|
class="form-control"
|
|
|
|
style="max-width: 250px;"
|
2020-10-27 17:29:19 +03:00
|
|
|
@blur="context.runValidation()"
|
2020-10-18 20:11:20 +03:00
|
|
|
>
|
2020-10-18 18:28:37 +03:00
|
|
|
|
|
|
|
<div
|
2020-10-26 17:00:18 +03:00
|
|
|
v-for="(error, index) in context.allErrors"
|
2020-10-18 18:28:37 +03:00
|
|
|
:key="index"
|
2020-10-18 20:11:20 +03:00
|
|
|
class="text-danger"
|
2020-10-18 18:28:37 +03:00
|
|
|
>
|
2020-10-26 17:00:18 +03:00
|
|
|
{{ error }}
|
2020-10-18 18:28:37 +03:00
|
|
|
</div>
|
|
|
|
</FormularioInput>
|
2020-10-18 20:11:20 +03:00
|
|
|
|
|
|
|
<div>{{ values }}</div>
|
2020-10-18 18:28:37 +03:00
|
|
|
</FormularioForm>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import FormularioForm from '@/FormularioForm'
|
|
|
|
import FormularioInput from '@/FormularioInput'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'FormularioInputTale',
|
|
|
|
|
|
|
|
components: {
|
|
|
|
FormularioForm,
|
|
|
|
FormularioInput,
|
|
|
|
},
|
|
|
|
|
|
|
|
data: () => ({
|
|
|
|
values: {},
|
2020-10-18 20:11:20 +03:00
|
|
|
}),
|
2020-10-18 18:28:37 +03:00
|
|
|
}
|
|
|
|
</script>
|