@@ -7,13 +7,13 @@ child elements, and so on deeper.
77
88``` vue{7-9}
99<template>
10- <form-field name="age" :validation="ageValidation"/>
10+ <form-field name="age" :validation="ageValidation"/>
1111</template>
1212<script setup>
1313import {Form, FormField} from "jenesius-vue-form";
1414
1515function ageValidation(x) {
16- return x > 17 || 'So small'
16+ return x > 17 || 'So small'
1717}
1818
1919form.setValues({ age: 17 });
@@ -30,7 +30,7 @@ For field validation, FormField takes one required parameter:
3030It has the following type:
3131``` ts
3232interface FormFieldProps {
33- validation: FormFieldValidationCallback [] | FormFieldValidationCallback // [!code focus]
33+ validation: FormFieldValidationCallback [] | FormFieldValidationCallback // [!code focus]
3434}
3535```
3636As you can see from the specification, the field can accept both a single function and an array of functions. The function type is described below:
@@ -47,14 +47,14 @@ type FormFieldValidationCallback = (value: any) => true | string | boolean
4747### Size limit
4848` ` ` vue
4949<template >
50- <form -field name = " token" : validation = " validation" />
50+ <form -field name = " token" : validation = " validation" />
5151</template >
5252<script setup >
5353import {FormField , Form } from " jenesius-vue-form" ;
5454
5555const validation = [
56- x => x .length > 5 || " That's too short. The minimum length is 5." ,
57- x => x .length < 25 || " Value length must be less than 25."
56+ x => x .length > 5 || " That's too short. The minimum length is 5." ,
57+ x => x .length < 25 || " Value length must be less than 25."
5858]
5959< / script >
6060```
@@ -69,22 +69,21 @@ In this example, there are two rules:
6969
7070``` vue{3}
7171<template>
72- <form-field type="switch" name="isAdmin"/>
73- <form-field name="login" :validation="validation"/>
72+ <form-field type="switch" name="isAdmin"/>
73+ <form-field name="login" :validation="validation"/>
7474</template>
7575<script setup>
7676import {FormField, Form, ComputedValue} from "jenesius-vue-form";
7777
7878const form = new Form();
7979const isAdmin = ComputedValue(form, "isAdmin"); // For reactive communication
8080const validation = [
81- login => {
82- if (isAdmin.value && !login.startsWith('$'))
83- return 'Administrator name must start with $';
84- if (!isAdmin.value && login.length < 5)
85- return 'Username must be at least 5 characters long.'
86-
87- return true;
81+ login => {
82+ if (isAdmin.value && !login.startsWith('$'))
83+ return 'Administrator name must start with $';
84+ if (!isAdmin.value && login.length < 5)
85+ return 'Username must be at least 5 characters long.'
86+ return true;
8887 }
8988]
9089</script>
0 commit comments