pwd.data.ts
1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { FormSchema } from '/@/components/Form';
import { InputRegExp } from '/@/enums/regexpEnum';
import { useI18n } from '/@/hooks/web/useI18n';
const { t } = useI18n();
export const formSchema: FormSchema[] = [
{
field: 'passwordOld',
label: t('common.currentPassword'),
component: 'InputPassword',
componentProps: {
placeholder: `${t('common.inputText')}${t('common.currentPassword')}`,
},
required: true,
},
{
field: 'passwordNew',
label: t('common.newPassword'),
component: 'InputPassword',
componentProps({ formModel, formActionType }) {
return {
onInput({ target }) {
const { value } = target;
const { confirmPassword } = formModel;
if (value === confirmPassword) {
formActionType.clearValidate('confirmPassword');
}
},
};
},
rules: [
{
required: true,
message: `${t('common.inputText')}${t('common.newPassword')}`,
},
],
},
{
field: 'confirmPassword',
label: t('common.confirmPassword'),
component: 'InputPassword',
componentProps: {
placeholder: `${t('common.inputText')}${t('common.confirmPassword')}`,
},
dynamicRules: ({ values }) => {
return [
{
required: true,
validator: (_, value) => {
if (!value) {
return Promise.reject(t('validator.emptyPassword'));
}
if (value !== values.passwordNew) {
return Promise.reject(t('validator.enteredPasswordsDiffer'));
}
const pwdRegex = new RegExp(InputRegExp.PASSWORD_INPUT);
if (!pwdRegex.test(value)) {
return Promise.reject(t('validator.passwordRegularization'));
}
return Promise.resolve();
},
},
];
},
},
];