@redneckz/wildless-cms-uni-blocks 0.14.590 → 0.14.591
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle/bundle.umd.js +63 -61
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/ui-kit/FormField/validators.d.ts +9 -9
- package/dist/ui-kit/FormField/Fields/MiddleNameField.js +3 -1
- package/dist/ui-kit/FormField/Fields/MiddleNameField.js.map +1 -1
- package/dist/ui-kit/FormField/getObjectValidator.js +46 -45
- package/dist/ui-kit/FormField/getObjectValidator.js.map +1 -1
- package/dist/ui-kit/FormField/validators.d.ts +9 -9
- package/dist/ui-kit/FormField/validators.js +17 -9
- package/dist/ui-kit/FormField/validators.js.map +1 -1
- package/dist/ui-kit/Input/Input.js +3 -2
- package/dist/ui-kit/Input/Input.js.map +1 -1
- package/lib/ui-kit/FormField/Fields/MiddleNameField.js +3 -1
- package/lib/ui-kit/FormField/Fields/MiddleNameField.js.map +1 -1
- package/lib/ui-kit/FormField/getObjectValidator.js +46 -45
- package/lib/ui-kit/FormField/getObjectValidator.js.map +1 -1
- package/lib/ui-kit/FormField/validators.d.ts +9 -9
- package/lib/ui-kit/FormField/validators.js +9 -9
- package/lib/ui-kit/FormField/validators.js.map +1 -1
- package/lib/ui-kit/Input/Input.js +3 -2
- package/lib/ui-kit/Input/Input.js.map +1 -1
- package/mobile/bundle/bundle.umd.js +63 -61
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/ui-kit/FormField/validators.d.ts +9 -9
- package/mobile/dist/ui-kit/FormField/Fields/MiddleNameField.js +3 -1
- package/mobile/dist/ui-kit/FormField/Fields/MiddleNameField.js.map +1 -1
- package/mobile/dist/ui-kit/FormField/getObjectValidator.js +46 -45
- package/mobile/dist/ui-kit/FormField/getObjectValidator.js.map +1 -1
- package/mobile/dist/ui-kit/FormField/validators.d.ts +9 -9
- package/mobile/dist/ui-kit/FormField/validators.js +17 -9
- package/mobile/dist/ui-kit/FormField/validators.js.map +1 -1
- package/mobile/dist/ui-kit/Input/Input.js +3 -2
- package/mobile/dist/ui-kit/Input/Input.js.map +1 -1
- package/mobile/lib/ui-kit/FormField/Fields/MiddleNameField.js +3 -1
- package/mobile/lib/ui-kit/FormField/Fields/MiddleNameField.js.map +1 -1
- package/mobile/lib/ui-kit/FormField/getObjectValidator.js +46 -45
- package/mobile/lib/ui-kit/FormField/getObjectValidator.js.map +1 -1
- package/mobile/lib/ui-kit/FormField/validators.d.ts +9 -9
- package/mobile/lib/ui-kit/FormField/validators.js +9 -9
- package/mobile/lib/ui-kit/FormField/validators.js.map +1 -1
- package/mobile/lib/ui-kit/Input/Input.js +3 -2
- package/mobile/lib/ui-kit/Input/Input.js.map +1 -1
- package/mobile/src/ui-kit/FormField/Fields/MiddleNameField.tsx +7 -1
- package/mobile/src/ui-kit/FormField/getObjectValidator.tsx +46 -45
- package/mobile/src/ui-kit/FormField/validators.ts +19 -18
- package/mobile/src/ui-kit/Input/Input.tsx +6 -2
- package/package.json +1 -1
- package/src/ui-kit/FormField/Fields/MiddleNameField.tsx +7 -1
- package/src/ui-kit/FormField/getObjectValidator.tsx +46 -45
- package/src/ui-kit/FormField/validators.ts +19 -18
- package/src/ui-kit/Input/Input.tsx +6 -2
|
@@ -16,50 +16,51 @@ import {
|
|
|
16
16
|
} from './validators';
|
|
17
17
|
|
|
18
18
|
export const validatorObj: Record<string, Validator> = {
|
|
19
|
-
typeForm: defaultValidator,
|
|
20
|
-
surname: nameValidator,
|
|
21
|
-
name: nameValidator,
|
|
19
|
+
typeForm: defaultValidator(),
|
|
20
|
+
surname: nameValidator('Укажите свою фамилию'),
|
|
21
|
+
name: nameValidator('Укажите своё имя'),
|
|
22
|
+
middleName: nameValidator('Укажите своё отчество'),
|
|
22
23
|
region: defaultSelectValidator,
|
|
23
24
|
addressBranch: defaultSelectValidator,
|
|
24
|
-
phone: phoneValidator,
|
|
25
|
-
secondaryPhone: phoneValidator,
|
|
26
|
-
birthday: defaultValidator,
|
|
27
|
-
education: defaultValidator,
|
|
28
|
-
housing: defaultValidator,
|
|
29
|
-
employment: defaultValidator,
|
|
30
|
-
organization: defaultValidator,
|
|
31
|
-
amountWorkers: defaultValidator,
|
|
32
|
-
employerActivities: defaultValidator,
|
|
33
|
-
employerOrganization: defaultValidator,
|
|
34
|
-
positionOrganization: defaultValidator,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
fullName: nameValidator,
|
|
42
|
-
inn: innValidator,
|
|
43
|
-
legalForm: defaultValidator,
|
|
44
|
-
organizationName: defaultValidator,
|
|
45
|
-
generalSeniority: defaultValidator,
|
|
46
|
-
lastJobExperience: defaultValidator,
|
|
47
|
-
experience5Years: defaultValidator,
|
|
48
|
-
jobsNumber: defaultValidator,
|
|
49
|
-
beginDate: defaultValidator,
|
|
50
|
-
fullAddress: defaultValidator,
|
|
51
|
-
partnerComments: defaultValidator,
|
|
52
|
-
collectionCount: defaultValidator,
|
|
53
|
-
comment: defaultValidator,
|
|
25
|
+
phone: phoneValidator('Укажите номер телефона'),
|
|
26
|
+
secondaryPhone: phoneValidator('Укажите номер телефона'),
|
|
27
|
+
birthday: defaultValidator('Укажите дату рождения'),
|
|
28
|
+
education: defaultValidator('Выберите ваше образование'),
|
|
29
|
+
housing: defaultValidator('Выберите тип жилья'),
|
|
30
|
+
employment: defaultValidator('Выберите информацию о трудоустройстве'),
|
|
31
|
+
organization: defaultValidator('Выберите тип организации'),
|
|
32
|
+
amountWorkers: defaultValidator('Выберите информацию о количестве сотрудников'),
|
|
33
|
+
employerActivities: defaultValidator('Выберите вид деятельности организации'),
|
|
34
|
+
employerOrganization: defaultValidator('Выберите вид организации'),
|
|
35
|
+
positionOrganization: defaultValidator('Выберите вашу должность'),
|
|
36
|
+
dulSerie: serieValidator('Укажите серию паспорта'),
|
|
37
|
+
dulNumber: numberValidator('Укажите номер паспорта'),
|
|
38
|
+
dulIssueDateField: defaultValidator('Укажите дату выдачи паспорта'),
|
|
39
|
+
dulSubdivisionCode: numberValidator('Укажите код подразделения'),
|
|
40
|
+
dulIssuedBy: defaultValidator('Укажите организацию, выдавшую паспорт'),
|
|
41
|
+
email: emailValidator('Укажите электронную почту'),
|
|
42
|
+
fullName: nameValidator(),
|
|
43
|
+
inn: innValidator('Укажите ИНН'),
|
|
44
|
+
legalForm: defaultValidator('Укажите ОПФ'),
|
|
45
|
+
organizationName: defaultValidator('Укажите наименование организации'),
|
|
46
|
+
generalSeniority: defaultValidator(),
|
|
47
|
+
lastJobExperience: defaultValidator('Укажите стаж на последнем месте работы'),
|
|
48
|
+
experience5Years: defaultValidator('Укажите общий стаж за последние 5 лет'),
|
|
49
|
+
jobsNumber: defaultValidator('Укажите количество лет стажа'),
|
|
50
|
+
beginDate: defaultValidator('Укажите дату заключения трудового договора'),
|
|
51
|
+
fullAddress: defaultValidator(),
|
|
52
|
+
partnerComments: defaultValidator(),
|
|
53
|
+
collectionCount: defaultValidator(),
|
|
54
|
+
comment: defaultValidator(),
|
|
54
55
|
acquiringType: defaultSelectValidator,
|
|
55
56
|
feedbackMethod: defaultSelectValidator,
|
|
56
57
|
serviceType: defaultSelectValidator,
|
|
57
58
|
serviceDirection: defaultSelectValidator,
|
|
58
|
-
meetingDay: defaultValidator,
|
|
59
|
-
product: defaultValidator,
|
|
60
|
-
localities: defaultValidator,
|
|
59
|
+
meetingDay: defaultValidator(),
|
|
60
|
+
product: defaultValidator(),
|
|
61
|
+
localities: defaultValidator(),
|
|
61
62
|
consentDataProcessing: agreementValidator,
|
|
62
|
-
annualRevenue: defaultValidator,
|
|
63
|
+
annualRevenue: defaultValidator(),
|
|
63
64
|
consentToReceiveMaterials: agreementValidator,
|
|
64
65
|
processPersonalDataLeadFlg: agreementValidator,
|
|
65
66
|
consentProviderFlg: agreementValidator,
|
|
@@ -68,14 +69,14 @@ export const validatorObj: Record<string, Validator> = {
|
|
|
68
69
|
consentAssignmentClaimsFlg: agreementValidator,
|
|
69
70
|
consentCollectionFlg: agreementValidator,
|
|
70
71
|
consentInformFlg: agreementValidator,
|
|
71
|
-
familyStatus: defaultValidator,
|
|
72
|
-
children: lengthStringValidator(2),
|
|
73
|
-
familyMembers: lengthStringValidator(2),
|
|
74
|
-
dependents: lengthStringValidator(2),
|
|
75
|
-
totalIncome: lengthStringValidator(19),
|
|
76
|
-
expenses: lengthStringValidator(10),
|
|
77
|
-
snils: snilsValidator,
|
|
78
|
-
conscription: defaultValidator,
|
|
72
|
+
familyStatus: defaultValidator('Выберите семейное положение'),
|
|
73
|
+
children: lengthStringValidator(2, 'Укажите количество детей'),
|
|
74
|
+
familyMembers: lengthStringValidator(2, 'Укажите количество членов семьи'),
|
|
75
|
+
dependents: lengthStringValidator(2, 'Укажите количество иждивенцев'),
|
|
76
|
+
totalIncome: lengthStringValidator(19, 'Укажите среднемесячный доход от основной зарплаты'),
|
|
77
|
+
expenses: lengthStringValidator(10, 'Укажите сумму обязательных выплат'),
|
|
78
|
+
snils: snilsValidator('Некорректный номер СНИЛС'),
|
|
79
|
+
conscription: defaultValidator(),
|
|
79
80
|
armyIdFlg: agreementValidator,
|
|
80
81
|
};
|
|
81
82
|
|
|
@@ -4,30 +4,30 @@ import { validator } from '../../validation/validator';
|
|
|
4
4
|
|
|
5
5
|
const ERROR_MESSAGE = 'Некорректно заполненное поле';
|
|
6
6
|
|
|
7
|
-
export const defaultValidator =
|
|
7
|
+
export const defaultValidator = (errorMsg?: string) =>
|
|
8
|
+
required(errorMsg ? errorMsg : ERROR_MESSAGE);
|
|
8
9
|
|
|
9
10
|
export const defaultSelectValidator = validator((_) => _?.key && _?.key !== '')(ERROR_MESSAGE);
|
|
10
11
|
|
|
11
|
-
export const nameValidator =
|
|
12
|
+
export const nameValidator = (errorMsg?: string) =>
|
|
13
|
+
validator((_) => typeof _ === 'string' && _.length > 1)(errorMsg ? errorMsg : ERROR_MESSAGE);
|
|
12
14
|
|
|
13
|
-
export const lengthStringValidator = (maxLength: number) =>
|
|
14
|
-
validator((_) => typeof _ === 'string' && _.length >= 1 && _.length <= maxLength)(
|
|
15
|
+
export const lengthStringValidator = (maxLength: number, errorMsg?: string) =>
|
|
16
|
+
validator((_) => typeof _ === 'string' && _.length >= 1 && _.length <= maxLength)(
|
|
17
|
+
errorMsg ? errorMsg : ERROR_MESSAGE,
|
|
18
|
+
);
|
|
15
19
|
|
|
16
|
-
export const serieValidator =
|
|
17
|
-
|
|
18
|
-
);
|
|
20
|
+
export const serieValidator = (errorMsg: string) =>
|
|
21
|
+
validator((_) => typeof _ === 'string' && _.length === 4)(errorMsg);
|
|
19
22
|
|
|
20
|
-
export const numberValidator =
|
|
21
|
-
|
|
22
|
-
);
|
|
23
|
+
export const numberValidator = (errorMsg: string) =>
|
|
24
|
+
validator((_) => typeof _ === 'string' && _.length === 6)(errorMsg);
|
|
23
25
|
|
|
24
|
-
export const innValidator =
|
|
25
|
-
(_) => typeof _ === 'string' && (_.length === 10 || _.length === 12)
|
|
26
|
-
)(ERROR_MESSAGE);
|
|
26
|
+
export const innValidator = (errorMsg: string) =>
|
|
27
|
+
validator((_) => typeof _ === 'string' && (_.length === 10 || _.length === 12))(errorMsg);
|
|
27
28
|
|
|
28
|
-
export const phoneValidator =
|
|
29
|
-
/^(\+7)?[\s-]?\(?[0-9]{3}\)?[\s-]?[0-9]{3}[\s-]?[0-9]{2}[\s-]?[0-9]{2}
|
|
30
|
-
)(ERROR_MESSAGE);
|
|
29
|
+
export const phoneValidator = (errorMsg: string) =>
|
|
30
|
+
pattern(/^(\+7)?[\s-]?\(?[0-9]{3}\)?[\s-]?[0-9]{3}[\s-]?[0-9]{2}[\s-]?[0-9]{2}$/)(errorMsg);
|
|
31
31
|
|
|
32
32
|
export const agreementValidator = validator((_) => typeof _ === 'boolean' && _)(
|
|
33
33
|
'Согласие обязательно',
|
|
@@ -53,8 +53,9 @@ const snilsValidate = (snils: string) => {
|
|
|
53
53
|
return false;
|
|
54
54
|
};
|
|
55
55
|
|
|
56
|
-
export const snilsValidator = validator(snilsValidate)(
|
|
56
|
+
export const snilsValidator = (errorMsg: string) => validator(snilsValidate)(errorMsg);
|
|
57
57
|
|
|
58
58
|
const emailValidate = (email: string) => /^[^\s@]+@[^\s@]+\.[a-zA-Z]{2}$/.test(email);
|
|
59
59
|
|
|
60
|
-
export const emailValidator =
|
|
60
|
+
export const emailValidator = (errorMsg: string) =>
|
|
61
|
+
validator((_: string) => emailValidate(_))(errorMsg);
|
|
@@ -25,9 +25,11 @@ export const Input = JSX<InputProps>(
|
|
|
25
25
|
isTextarea = false,
|
|
26
26
|
}) => {
|
|
27
27
|
const inputRef = useRef<HTMLInputElement | null>(null);
|
|
28
|
+
|
|
28
29
|
const handleChange = useCallback(
|
|
29
30
|
(e: { target?: { value?: string } }) => {
|
|
30
|
-
|
|
31
|
+
const valueWithoutSpace = (e.target?.value || '').trimStart();
|
|
32
|
+
onChange && onChange(valueWithoutSpace);
|
|
31
33
|
},
|
|
32
34
|
[onChange],
|
|
33
35
|
);
|
|
@@ -37,7 +39,7 @@ export const Input = JSX<InputProps>(
|
|
|
37
39
|
inputRef.current?.focus();
|
|
38
40
|
}
|
|
39
41
|
}, [autoFocus, inputRef]);
|
|
40
|
-
|
|
42
|
+
|
|
41
43
|
const paddingStyle = children ? 'pr-3xl' : '';
|
|
42
44
|
const validStyle = getValidStyle(valid);
|
|
43
45
|
|
|
@@ -81,3 +83,5 @@ export const Input = JSX<InputProps>(
|
|
|
81
83
|
);
|
|
82
84
|
|
|
83
85
|
const getValidStyle = (valid: boolean) => (valid ? inputValidStyle : 'border-error');
|
|
86
|
+
|
|
87
|
+
const defaultStyle = 'w-full border rounded-md text-primary-text outline-none p-m';
|
package/package.json
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
2
|
import { InputControl } from '../../Input/InputControl';
|
|
3
3
|
import { type CustomFieldProps } from '../CustomFieldProps';
|
|
4
|
+
import { validatorObj } from '../getObjectValidator';
|
|
5
|
+
import { getValidation } from '../getValidation';
|
|
4
6
|
|
|
5
7
|
export const MiddleNameField = JSX<CustomFieldProps>(({ field, input }) => (
|
|
6
|
-
<InputControl
|
|
8
|
+
<InputControl
|
|
9
|
+
label="Отчество (Обязательно, при наличии)"
|
|
10
|
+
{...getValidation(field('middleName'), validatorObj.middleName)}
|
|
11
|
+
{...input}
|
|
12
|
+
/>
|
|
7
13
|
));
|
|
@@ -16,50 +16,51 @@ import {
|
|
|
16
16
|
} from './validators';
|
|
17
17
|
|
|
18
18
|
export const validatorObj: Record<string, Validator> = {
|
|
19
|
-
typeForm: defaultValidator,
|
|
20
|
-
surname: nameValidator,
|
|
21
|
-
name: nameValidator,
|
|
19
|
+
typeForm: defaultValidator(),
|
|
20
|
+
surname: nameValidator('Укажите свою фамилию'),
|
|
21
|
+
name: nameValidator('Укажите своё имя'),
|
|
22
|
+
middleName: nameValidator('Укажите своё отчество'),
|
|
22
23
|
region: defaultSelectValidator,
|
|
23
24
|
addressBranch: defaultSelectValidator,
|
|
24
|
-
phone: phoneValidator,
|
|
25
|
-
secondaryPhone: phoneValidator,
|
|
26
|
-
birthday: defaultValidator,
|
|
27
|
-
education: defaultValidator,
|
|
28
|
-
housing: defaultValidator,
|
|
29
|
-
employment: defaultValidator,
|
|
30
|
-
organization: defaultValidator,
|
|
31
|
-
amountWorkers: defaultValidator,
|
|
32
|
-
employerActivities: defaultValidator,
|
|
33
|
-
employerOrganization: defaultValidator,
|
|
34
|
-
positionOrganization: defaultValidator,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
fullName: nameValidator,
|
|
42
|
-
inn: innValidator,
|
|
43
|
-
legalForm: defaultValidator,
|
|
44
|
-
organizationName: defaultValidator,
|
|
45
|
-
generalSeniority: defaultValidator,
|
|
46
|
-
lastJobExperience: defaultValidator,
|
|
47
|
-
experience5Years: defaultValidator,
|
|
48
|
-
jobsNumber: defaultValidator,
|
|
49
|
-
beginDate: defaultValidator,
|
|
50
|
-
fullAddress: defaultValidator,
|
|
51
|
-
partnerComments: defaultValidator,
|
|
52
|
-
collectionCount: defaultValidator,
|
|
53
|
-
comment: defaultValidator,
|
|
25
|
+
phone: phoneValidator('Укажите номер телефона'),
|
|
26
|
+
secondaryPhone: phoneValidator('Укажите номер телефона'),
|
|
27
|
+
birthday: defaultValidator('Укажите дату рождения'),
|
|
28
|
+
education: defaultValidator('Выберите ваше образование'),
|
|
29
|
+
housing: defaultValidator('Выберите тип жилья'),
|
|
30
|
+
employment: defaultValidator('Выберите информацию о трудоустройстве'),
|
|
31
|
+
organization: defaultValidator('Выберите тип организации'),
|
|
32
|
+
amountWorkers: defaultValidator('Выберите информацию о количестве сотрудников'),
|
|
33
|
+
employerActivities: defaultValidator('Выберите вид деятельности организации'),
|
|
34
|
+
employerOrganization: defaultValidator('Выберите вид организации'),
|
|
35
|
+
positionOrganization: defaultValidator('Выберите вашу должность'),
|
|
36
|
+
dulSerie: serieValidator('Укажите серию паспорта'),
|
|
37
|
+
dulNumber: numberValidator('Укажите номер паспорта'),
|
|
38
|
+
dulIssueDateField: defaultValidator('Укажите дату выдачи паспорта'),
|
|
39
|
+
dulSubdivisionCode: numberValidator('Укажите код подразделения'),
|
|
40
|
+
dulIssuedBy: defaultValidator('Укажите организацию, выдавшую паспорт'),
|
|
41
|
+
email: emailValidator('Укажите электронную почту'),
|
|
42
|
+
fullName: nameValidator(),
|
|
43
|
+
inn: innValidator('Укажите ИНН'),
|
|
44
|
+
legalForm: defaultValidator('Укажите ОПФ'),
|
|
45
|
+
organizationName: defaultValidator('Укажите наименование организации'),
|
|
46
|
+
generalSeniority: defaultValidator(),
|
|
47
|
+
lastJobExperience: defaultValidator('Укажите стаж на последнем месте работы'),
|
|
48
|
+
experience5Years: defaultValidator('Укажите общий стаж за последние 5 лет'),
|
|
49
|
+
jobsNumber: defaultValidator('Укажите количество лет стажа'),
|
|
50
|
+
beginDate: defaultValidator('Укажите дату заключения трудового договора'),
|
|
51
|
+
fullAddress: defaultValidator(),
|
|
52
|
+
partnerComments: defaultValidator(),
|
|
53
|
+
collectionCount: defaultValidator(),
|
|
54
|
+
comment: defaultValidator(),
|
|
54
55
|
acquiringType: defaultSelectValidator,
|
|
55
56
|
feedbackMethod: defaultSelectValidator,
|
|
56
57
|
serviceType: defaultSelectValidator,
|
|
57
58
|
serviceDirection: defaultSelectValidator,
|
|
58
|
-
meetingDay: defaultValidator,
|
|
59
|
-
product: defaultValidator,
|
|
60
|
-
localities: defaultValidator,
|
|
59
|
+
meetingDay: defaultValidator(),
|
|
60
|
+
product: defaultValidator(),
|
|
61
|
+
localities: defaultValidator(),
|
|
61
62
|
consentDataProcessing: agreementValidator,
|
|
62
|
-
annualRevenue: defaultValidator,
|
|
63
|
+
annualRevenue: defaultValidator(),
|
|
63
64
|
consentToReceiveMaterials: agreementValidator,
|
|
64
65
|
processPersonalDataLeadFlg: agreementValidator,
|
|
65
66
|
consentProviderFlg: agreementValidator,
|
|
@@ -68,14 +69,14 @@ export const validatorObj: Record<string, Validator> = {
|
|
|
68
69
|
consentAssignmentClaimsFlg: agreementValidator,
|
|
69
70
|
consentCollectionFlg: agreementValidator,
|
|
70
71
|
consentInformFlg: agreementValidator,
|
|
71
|
-
familyStatus: defaultValidator,
|
|
72
|
-
children: lengthStringValidator(2),
|
|
73
|
-
familyMembers: lengthStringValidator(2),
|
|
74
|
-
dependents: lengthStringValidator(2),
|
|
75
|
-
totalIncome: lengthStringValidator(19),
|
|
76
|
-
expenses: lengthStringValidator(10),
|
|
77
|
-
snils: snilsValidator,
|
|
78
|
-
conscription: defaultValidator,
|
|
72
|
+
familyStatus: defaultValidator('Выберите семейное положение'),
|
|
73
|
+
children: lengthStringValidator(2, 'Укажите количество детей'),
|
|
74
|
+
familyMembers: lengthStringValidator(2, 'Укажите количество членов семьи'),
|
|
75
|
+
dependents: lengthStringValidator(2, 'Укажите количество иждивенцев'),
|
|
76
|
+
totalIncome: lengthStringValidator(19, 'Укажите среднемесячный доход от основной зарплаты'),
|
|
77
|
+
expenses: lengthStringValidator(10, 'Укажите сумму обязательных выплат'),
|
|
78
|
+
snils: snilsValidator('Некорректный номер СНИЛС'),
|
|
79
|
+
conscription: defaultValidator(),
|
|
79
80
|
armyIdFlg: agreementValidator,
|
|
80
81
|
};
|
|
81
82
|
|
|
@@ -4,30 +4,30 @@ import { validator } from '../../validation/validator';
|
|
|
4
4
|
|
|
5
5
|
const ERROR_MESSAGE = 'Некорректно заполненное поле';
|
|
6
6
|
|
|
7
|
-
export const defaultValidator =
|
|
7
|
+
export const defaultValidator = (errorMsg?: string) =>
|
|
8
|
+
required(errorMsg ? errorMsg : ERROR_MESSAGE);
|
|
8
9
|
|
|
9
10
|
export const defaultSelectValidator = validator((_) => _?.key && _?.key !== '')(ERROR_MESSAGE);
|
|
10
11
|
|
|
11
|
-
export const nameValidator =
|
|
12
|
+
export const nameValidator = (errorMsg?: string) =>
|
|
13
|
+
validator((_) => typeof _ === 'string' && _.length > 1)(errorMsg ? errorMsg : ERROR_MESSAGE);
|
|
12
14
|
|
|
13
|
-
export const lengthStringValidator = (maxLength: number) =>
|
|
14
|
-
validator((_) => typeof _ === 'string' && _.length >= 1 && _.length <= maxLength)(
|
|
15
|
+
export const lengthStringValidator = (maxLength: number, errorMsg?: string) =>
|
|
16
|
+
validator((_) => typeof _ === 'string' && _.length >= 1 && _.length <= maxLength)(
|
|
17
|
+
errorMsg ? errorMsg : ERROR_MESSAGE,
|
|
18
|
+
);
|
|
15
19
|
|
|
16
|
-
export const serieValidator =
|
|
17
|
-
|
|
18
|
-
);
|
|
20
|
+
export const serieValidator = (errorMsg: string) =>
|
|
21
|
+
validator((_) => typeof _ === 'string' && _.length === 4)(errorMsg);
|
|
19
22
|
|
|
20
|
-
export const numberValidator =
|
|
21
|
-
|
|
22
|
-
);
|
|
23
|
+
export const numberValidator = (errorMsg: string) =>
|
|
24
|
+
validator((_) => typeof _ === 'string' && _.length === 6)(errorMsg);
|
|
23
25
|
|
|
24
|
-
export const innValidator =
|
|
25
|
-
(_) => typeof _ === 'string' && (_.length === 10 || _.length === 12)
|
|
26
|
-
)(ERROR_MESSAGE);
|
|
26
|
+
export const innValidator = (errorMsg: string) =>
|
|
27
|
+
validator((_) => typeof _ === 'string' && (_.length === 10 || _.length === 12))(errorMsg);
|
|
27
28
|
|
|
28
|
-
export const phoneValidator =
|
|
29
|
-
/^(\+7)?[\s-]?\(?[0-9]{3}\)?[\s-]?[0-9]{3}[\s-]?[0-9]{2}[\s-]?[0-9]{2}
|
|
30
|
-
)(ERROR_MESSAGE);
|
|
29
|
+
export const phoneValidator = (errorMsg: string) =>
|
|
30
|
+
pattern(/^(\+7)?[\s-]?\(?[0-9]{3}\)?[\s-]?[0-9]{3}[\s-]?[0-9]{2}[\s-]?[0-9]{2}$/)(errorMsg);
|
|
31
31
|
|
|
32
32
|
export const agreementValidator = validator((_) => typeof _ === 'boolean' && _)(
|
|
33
33
|
'Согласие обязательно',
|
|
@@ -53,8 +53,9 @@ const snilsValidate = (snils: string) => {
|
|
|
53
53
|
return false;
|
|
54
54
|
};
|
|
55
55
|
|
|
56
|
-
export const snilsValidator = validator(snilsValidate)(
|
|
56
|
+
export const snilsValidator = (errorMsg: string) => validator(snilsValidate)(errorMsg);
|
|
57
57
|
|
|
58
58
|
const emailValidate = (email: string) => /^[^\s@]+@[^\s@]+\.[a-zA-Z]{2}$/.test(email);
|
|
59
59
|
|
|
60
|
-
export const emailValidator =
|
|
60
|
+
export const emailValidator = (errorMsg: string) =>
|
|
61
|
+
validator((_: string) => emailValidate(_))(errorMsg);
|
|
@@ -25,9 +25,11 @@ export const Input = JSX<InputProps>(
|
|
|
25
25
|
isTextarea = false,
|
|
26
26
|
}) => {
|
|
27
27
|
const inputRef = useRef<HTMLInputElement | null>(null);
|
|
28
|
+
|
|
28
29
|
const handleChange = useCallback(
|
|
29
30
|
(e: { target?: { value?: string } }) => {
|
|
30
|
-
|
|
31
|
+
const valueWithoutSpace = (e.target?.value || '').trimStart();
|
|
32
|
+
onChange && onChange(valueWithoutSpace);
|
|
31
33
|
},
|
|
32
34
|
[onChange],
|
|
33
35
|
);
|
|
@@ -37,7 +39,7 @@ export const Input = JSX<InputProps>(
|
|
|
37
39
|
inputRef.current?.focus();
|
|
38
40
|
}
|
|
39
41
|
}, [autoFocus, inputRef]);
|
|
40
|
-
|
|
42
|
+
|
|
41
43
|
const paddingStyle = children ? 'pr-3xl' : '';
|
|
42
44
|
const validStyle = getValidStyle(valid);
|
|
43
45
|
|
|
@@ -81,3 +83,5 @@ export const Input = JSX<InputProps>(
|
|
|
81
83
|
);
|
|
82
84
|
|
|
83
85
|
const getValidStyle = (valid: boolean) => (valid ? inputValidStyle : 'border-error');
|
|
86
|
+
|
|
87
|
+
const defaultStyle = 'w-full border rounded-md text-primary-text outline-none p-m';
|