WIP update validation for phone.

This commit is contained in:
Bryan Mauger 2023-05-17 08:36:40 -04:00
parent ca05c03fc5
commit eb70fda412

View file

@ -22,12 +22,15 @@
</template> </template>
<script> <script>
import { useField, validate } from "vee-validate";
export default { export default {
name: "phoneNumberQuestion", name: "phoneNumberQuestion",
props: { props: {
cmsWidgetName: String, cmsWidgetName: String,
isRequired: Boolean, isRequired: Boolean,
validationRules: String, validationRules: String,
hasError: Boolean,
centerErrorMessage: Boolean,
}, },
setup(props) { setup(props) {
const inputId = !props.customInputId ? `input-${crypto.randomUUID()}` : props.customInputId; const inputId = !props.customInputId ? `input-${crypto.randomUUID()}` : props.customInputId;
@ -50,6 +53,22 @@ export default {
value: modelValue, value: modelValue,
initialValue: initialValue, initialValue: initialValue,
}; };
const { errorMessage, handleBlur, handleChange, meta, validate, errors } = useField(
inputId,
props.validationRules,
fieldOptions
);
return {
inputId,
errorMessage,
handleBlur,
handleChange,
validate,
meta,
errors,
};
}, },
data() { data() {
return { return {