@weareconceptstudio/form 0.2.3 → 0.2.4

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.
@@ -2,7 +2,7 @@ import React, { useCallback, forwardRef, useImperativeHandle } from 'react';
2
2
  import { FormProvider, useForm } from 'react-hook-form';
3
3
  import { Text } from '@weareconceptstudio/core';
4
4
  import classNames from 'classnames';
5
- const BaseForm = forwardRef(({ initialValues: defaultValues, values, children, onSubmit, mode = 'onChange', reValidateMode = 'onChange', errors, resetOptions, criteriaMode = 'firstError', shouldFocusError, delayError = 0, shouldUseNativeValidation, shouldUnregister, className }, ref) => {
5
+ const BaseForm = forwardRef(({ initialValues: defaultValues, values, children, onSubmit, mode = 'onBlur', reValidateMode = 'onChange', errors, resetOptions, criteriaMode = 'firstError', shouldFocusError, delayError = 0, shouldUseNativeValidation, shouldUnregister, className }, ref) => {
6
6
  const methods = useForm({
7
7
  mode,
8
8
  errors,
@@ -33,7 +33,7 @@ const BaseForm = forwardRef(({ initialValues: defaultValues, values, children, o
33
33
  else {
34
34
  methods.setError('root.serverError', {
35
35
  type: String(status),
36
- message: data?.message || 'serverError',
36
+ message: data?.message || 'form.serverError',
37
37
  });
38
38
  }
39
39
  });
@@ -47,7 +47,7 @@ const BaseForm = forwardRef(({ initialValues: defaultValues, values, children, o
47
47
  return (React.createElement(FormProvider, { ...methods },
48
48
  methods.formState.errors.root?.serverError && (React.createElement("div", { className: 'global-error-wrap' },
49
49
  React.createElement(Text, { className: 'backend-error', text: methods.formState.errors.root?.serverError.message }),
50
- React.createElement(Text, { className: 'frontend-error', text: 'globalError' }))),
50
+ React.createElement(Text, { className: 'frontend-error', text: 'form.globalError' }))),
51
51
  React.createElement("form", { onSubmit: methods.handleSubmit(handleSubmit), className: classNames({
52
52
  [className]: !!className,
53
53
  }) }, children)));
@@ -1,11 +1,12 @@
1
1
  import React, { useMemo } from 'react';
2
+ import { isValidPhoneNumber } from 'react-phone-number-input';
2
3
  import { useTranslation } from '@weareconceptstudio/core';
3
4
  export const validationPatterns = ({ type, pattern, message, translate }) => {
4
5
  switch (type) {
5
6
  case 'email':
6
- return { value: /^[^\s@]+@[^\s@]+\.[^\s@]+$/g, message: message || translate('validateMessages.email') };
7
+ return { value: /^[^\s@]+@[^\s@]+\.[^\s@]+$/g, message: message || translate('form.validateMessages.email') };
7
8
  case 'new-password':
8
- return { value: /(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}/, message: message || translate('validateMessages.password') };
9
+ return { value: /.{8,}/, message: message || translate('form.validateMessages.password') };
9
10
  case 'number':
10
11
  return { value: /[0-9]/g, message };
11
12
  default:
@@ -21,11 +22,22 @@ export const useRules = ({ rules, required, requiredMessage, childType, errorKey
21
22
  if (childType.toLowerCase() === 'input' || childType.toLowerCase() === 'textarea') {
22
23
  r.push({
23
24
  validator: (value) => {
24
- return value?.trim().length > 0 || translate('validateMessages.whitespace', { errorKey: translate(errorKey) });
25
+ return value?.trim().length > 0 || translate('form.validateMessages.whitespace', { errorKey: translate(errorKey) });
25
26
  },
26
27
  });
27
28
  }
28
29
  }
30
+ if (childType.toLowerCase() === 'phone') {
31
+ r.push({
32
+ validator: (value) => {
33
+ if (required || value.length > 0) {
34
+ return isValidPhoneNumber(value);
35
+ }
36
+ return true;
37
+ },
38
+ message: translate('form.validateMessages.phone', { errorKey: translate(errorKey) }),
39
+ });
40
+ }
29
41
  return r;
30
42
  }, [rules, required, requiredMessage, childType, errorKey]);
31
43
  };
@@ -33,7 +45,7 @@ export const mapValidationRules = (errorKey, rules) => {
33
45
  const { translate } = useTranslation();
34
46
  return rules?.reduce((acc, rule) => {
35
47
  if (rule.required) {
36
- acc.required = rule.message || translate('validateMessages.required', { errorKey: translate(errorKey) });
48
+ acc.required = rule.message || translate('form.validateMessages.required', { errorKey: translate(errorKey) });
37
49
  }
38
50
  if (rule.pattern || rule.type) {
39
51
  acc.pattern = validationPatterns({ ...rule, translate });
@@ -1,8 +1,3 @@
1
1
  export default PhoneNumber;
2
- declare function PhoneNumber({ name, className, autoComplete, options }: {
3
- name: any;
4
- className: any;
5
- autoComplete?: string;
6
- options?: {};
7
- }): React.JSX.Element;
2
+ declare const PhoneNumber: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
8
3
  import React from 'react';
@@ -1,18 +1,35 @@
1
- import React from 'react';
1
+ import React, { forwardRef, useImperativeHandle, useEffect } from 'react';
2
2
  import classNames from 'classnames';
3
3
  import PhoneInput from 'react-phone-number-input/input';
4
+ import { parsePhoneNumber } from 'react-phone-number-input';
4
5
  import useFormInstance from '../form/hooks/useFormInstance';
5
6
  import { Controller } from 'react-hook-form';
6
- const PhoneNumber = ({ name, className, autoComplete = 'new-password', options = {} }) => {
7
+ const PhoneNumber = forwardRef(({ name, className, autoComplete = 'new-password', country = 'AM', maxLength = 14, options = {} }, ref) => {
8
+ useImperativeHandle(ref, () => ({ childType: 'phone' }));
7
9
  const { control, setValue, getValues, trigger } = useFormInstance();
8
10
  const classString = classNames('phone-number-input', {
9
11
  [className]: className,
10
12
  });
11
- return (React.createElement(Controller, { name: name, control: control, render: ({ field: { onChange, value, onBlur } }) => (React.createElement(PhoneInput, { name: name, country: 'AM', maxLength: 14, international: true, withCountryCallingCode: true, className: classString, autoComplete: autoComplete, value: getValues(name), onChange: (value) => {
12
- setValue(name, value);
13
- trigger(name);
14
- }, onBlur: () => {
15
- onBlur();
16
- }, ...options })) }));
17
- };
13
+ useEffect(() => {
14
+ let defaultValue = getValues(name);
15
+ try {
16
+ if (defaultValue && !defaultValue.startsWith('+')) {
17
+ const parsed = parsePhoneNumber(defaultValue, country);
18
+ if (parsed)
19
+ defaultValue = parsed.number;
20
+ }
21
+ }
22
+ catch (e) { }
23
+ setValue(name, defaultValue);
24
+ }, [name, getValues, setValue, country]);
25
+ return (React.createElement(Controller, { name: name, control: control, render: ({ field: { onChange, value, onBlur } }) => {
26
+ return (React.createElement(PhoneInput, { name: name, international: true, value: value, country: country, maxLength: maxLength, withCountryCallingCode: true, className: classString, autoComplete: autoComplete, onChange: (value) => {
27
+ onChange({ value: value || '' });
28
+ setValue(name, value || '');
29
+ trigger(name);
30
+ }, onBlur: () => {
31
+ onBlur();
32
+ }, ...options }));
33
+ } }));
34
+ });
18
35
  export default PhoneNumber;
@@ -1,38 +1,41 @@
1
1
  declare const _default: {
2
- serverError: string;
3
- globalError: string;
4
- validateMessages: {
5
- default: string;
6
- required: string;
7
- email: string;
8
- password: string;
9
- enum: string;
10
- whitespace: string;
11
- date: {
12
- format: string;
13
- parse: string;
14
- invalid: string;
15
- };
16
- string: {
17
- len: string;
18
- min: string;
19
- max: string;
20
- range: string;
21
- };
22
- number: {
23
- len: string;
24
- min: string;
25
- max: string;
26
- range: string;
27
- };
28
- array: {
29
- len: string;
30
- min: string;
31
- max: string;
32
- range: string;
33
- };
34
- pattern: {
35
- mismatch: string;
2
+ form: {
3
+ serverError: string;
4
+ globalError: string;
5
+ validateMessages: {
6
+ default: string;
7
+ required: string;
8
+ email: string;
9
+ password: string;
10
+ enum: string;
11
+ whitespace: string;
12
+ phone: string;
13
+ date: {
14
+ format: string;
15
+ parse: string;
16
+ invalid: string;
17
+ };
18
+ string: {
19
+ len: string;
20
+ min: string;
21
+ max: string;
22
+ range: string;
23
+ };
24
+ number: {
25
+ len: string;
26
+ min: string;
27
+ max: string;
28
+ range: string;
29
+ };
30
+ array: {
31
+ len: string;
32
+ min: string;
33
+ max: string;
34
+ range: string;
35
+ };
36
+ pattern: {
37
+ mismatch: string;
38
+ };
36
39
  };
37
40
  };
38
41
  };
@@ -1,38 +1,41 @@
1
1
  export default {
2
- serverError: 'Ups! there is something wrong with the website administration.',
3
- globalError: 'Please double-check the required fields and confirm again.',
4
- validateMessages: {
5
- default: 'Validation error on field {errorKey}',
6
- required: 'Please enter your {errorKey}',
7
- email: 'Please enter a valid email address',
8
- password: 'Password must contain lowercase, uppercase, number and has been min 8 characters.',
9
- enum: '{errorKey} must be one of [{enum}]',
10
- whitespace: '{errorKey} cannot be empty',
11
- date: {
12
- format: '{errorKey} is invalid for format date',
13
- parse: '{errorKey} could not be parsed as date',
14
- invalid: '{errorKey} is invalid date',
15
- },
16
- string: {
17
- len: '{errorKey} must be exactly {len} characters',
18
- min: '{errorKey} must be at least {min} characters',
19
- max: '{errorKey} cannot be longer than ${max} characters',
20
- range: '{errorKey} must be between {min} and {max} characters',
21
- },
22
- number: {
23
- len: '{errorKey} must equal {len}',
24
- min: '{errorKey} cannot be less than {min}',
25
- max: '{errorKey} cannot be greater than {max}',
26
- range: '{errorKey} must be between {min} and {max}',
27
- },
28
- array: {
29
- len: '{errorKey} must be exactly {len} in length',
30
- min: '{errorKey} cannot be less than {min} in length',
31
- max: '{errorKey} cannot be greater than {max} in length',
32
- range: '{errorKey} must be between {min} and {max} in length',
33
- },
34
- pattern: {
35
- mismatch: '{errorKey} does not match pattern {pattern}',
2
+ form: {
3
+ serverError: 'Ups! there is something wrong with the website administration.',
4
+ globalError: 'Please double-check the required fields and confirm again.',
5
+ validateMessages: {
6
+ default: 'Validation error on field {errorKey}.',
7
+ required: 'Please enter your {errorKey}.',
8
+ email: 'Please enter a valid email address.',
9
+ password: 'The Password Must Be At Least 8 characters.',
10
+ enum: '{errorKey} must be one of [{enum}].',
11
+ whitespace: '{errorKey} cannot be empty.',
12
+ phone: 'Please enter a valid {errorKey}.',
13
+ date: {
14
+ format: '{errorKey} is invalid for format date.',
15
+ parse: '{errorKey} could not be parsed as date.',
16
+ invalid: '{errorKey} is invalid date.',
17
+ },
18
+ string: {
19
+ len: '{errorKey} must be exactly {len} characters.',
20
+ min: '{errorKey} must be at least {min} characters.',
21
+ max: '{errorKey} cannot be longer than ${max} characters.',
22
+ range: '{errorKey} must be between {min} and {max} characters.',
23
+ },
24
+ number: {
25
+ len: '{errorKey} must equal {len}.',
26
+ min: '{errorKey} cannot be less than {min}.',
27
+ max: '{errorKey} cannot be greater than {max}.',
28
+ range: '{errorKey} must be between {min} and {max}.',
29
+ },
30
+ array: {
31
+ len: '{errorKey} must be exactly {len} in length.',
32
+ min: '{errorKey} cannot be less than {min} in length.',
33
+ max: '{errorKey} cannot be greater than {max} in length.',
34
+ range: '{errorKey} must be between {min} and {max} in length.',
35
+ },
36
+ pattern: {
37
+ mismatch: '{errorKey} does not match pattern {pattern}.',
38
+ },
36
39
  },
37
40
  },
38
41
  };
@@ -1,38 +1,41 @@
1
1
  declare const _default: {
2
- serverError: string;
3
- globalError: string;
4
- validateMessages: {
5
- default: string;
6
- required: string;
7
- email: string;
8
- password: string;
9
- enum: string;
10
- whitespace: string;
11
- date: {
12
- format: string;
13
- parse: string;
14
- invalid: string;
15
- };
16
- string: {
17
- len: string;
18
- min: string;
19
- max: string;
20
- range: string;
21
- };
22
- number: {
23
- len: string;
24
- min: string;
25
- max: string;
26
- range: string;
27
- };
28
- array: {
29
- len: string;
30
- min: string;
31
- max: string;
32
- range: string;
33
- };
34
- pattern: {
35
- mismatch: string;
2
+ form: {
3
+ serverError: string;
4
+ globalError: string;
5
+ validateMessages: {
6
+ default: string;
7
+ required: string;
8
+ email: string;
9
+ password: string;
10
+ enum: string;
11
+ whitespace: string;
12
+ phone: string;
13
+ date: {
14
+ format: string;
15
+ parse: string;
16
+ invalid: string;
17
+ };
18
+ string: {
19
+ len: string;
20
+ min: string;
21
+ max: string;
22
+ range: string;
23
+ };
24
+ number: {
25
+ len: string;
26
+ min: string;
27
+ max: string;
28
+ range: string;
29
+ };
30
+ array: {
31
+ len: string;
32
+ min: string;
33
+ max: string;
34
+ range: string;
35
+ };
36
+ pattern: {
37
+ mismatch: string;
38
+ };
36
39
  };
37
40
  };
38
41
  };
@@ -1,38 +1,41 @@
1
1
  export default {
2
- serverError: 'Ողջույն! Կայքի ադմինիստրացիայում խնդիր կա:',
3
- globalError: 'Խնդրում ենք կրկին ստուգել պահանջվող դաշտերը և հաստատել:',
4
- validateMessages: {
5
- default: 'Դաշտի {errorKey}-ի համար վավերացման սխալ',
6
- required: 'Խնդրում ենք մուտքագրել ձեր {errorKey}-ը',
7
- email: 'Խնդրում ենք մուտքագրել վավեր էլ. հասցե:',
8
- password: 'Գաղտնաբառը պետք է պարունակի փոքրատառեր, մեծատառեր, թիվ և լինի նվազագույնը 8 նիշ:',
9
- enum: '{errorKey}-ը պետք է լինի [{enum}] արժեքներից մեկը',
10
- whitespace: '{errorKey} չի կարող դատարկ լինել',
11
- date: {
12
- format: '{errorKey}-ի ֆորմատը անվավեր է',
13
- parse: '{errorKey}-ը չի կարող անցնել որպես ամսաթիվ',
14
- invalid: '{errorKey} անվավեր ամսաթիվ է',
15
- },
16
- string: {
17
- len: '{errorKey}-ը պետք է լինի ճիշտ {len} նիշ',
18
- min: '{errorKey}-ը պետք է լինի առնվազն {min} նիշ',
19
- max: '{errorKey} չի կարող լինել {max} նիշից երկար',
20
- range: '{errorKey} պետք է լինի {min} և {max} նիշերի միջև',
21
- },
22
- number: {
23
- len: '{errorKey}-ը պետք է հավասար լինի {len}-ին',
24
- min: '{errorKey}-ը չի կարող լինել {min}-ից պակաս',
25
- max: '{errorKey} չի կարող լինել {max}-ից ավելին',
26
- range: '{errorKey} պետք է լինի {min} և {max} միջև',
27
- },
28
- array: {
29
- len: '{errorKey}-ը պետք է լինի ճիշտ {len} երկարություն',
30
- min: '{errorKey}-ը չի կարող լինել {min}-ից պակաս երկարությամբ',
31
- max: '{errorKey} չի կարող լինել {max}-ից ավել երկարությամբ',
32
- range: '{errorKey} պետք է լինի {min} և {max} երկարության միջև',
33
- },
34
- pattern: {
35
- mismatch: '{errorKey}-ը չի համապատասխանում {pattern} օրինաչափությանը',
2
+ form: {
3
+ serverError: 'Ողջույն! Կայքի ադմինիստրացիայում խնդիր կա:',
4
+ globalError: 'Խնդրում ենք կրկին ստուգել պահանջվող դաշտերը և հաստատել:',
5
+ validateMessages: {
6
+ default: 'Դաշտի {errorKey}ի համար վավերացման սխալ:',
7
+ required: 'Խնդրում ենք մուտքագրել ձեր {errorKey}ը:',
8
+ email: 'Խնդրում ենք մուտքագրել վավեր էլ. հասցե:',
9
+ password: 'Գաղտնաբառը պետք է ունենա առնվազն 8 նիշ:',
10
+ enum: '{errorKey}ը պետք է լինի [{enum}] արժեքներից մեկը:',
11
+ whitespace: '{errorKey}ը չի կարող դատարկ լինել:',
12
+ phone: 'Խնդրում ենք մուտքագրել վավեր {errorKey}:',
13
+ date: {
14
+ format: '{errorKey}ի ֆորմատը անվավեր է:',
15
+ parse: '{errorKey}ը չի կարող անցնել որպես ամսաթիվ:',
16
+ invalid: '{errorKey}ը անվավեր ամսաթիվ է:',
17
+ },
18
+ string: {
19
+ len: '{errorKey}ը պետք է լինի ճիշտ {len} նիշ:',
20
+ min: '{errorKey}ը պետք է լինի առնվազն {min} նիշ:',
21
+ max: '{errorKey}ը չի կարող լինել {max} նիշից երկար:',
22
+ range: '{errorKey}ը պետք է լինի {min} և {max} նիշերի միջև:',
23
+ },
24
+ number: {
25
+ len: '{errorKey}ը պետք է հավասար լինի {len}-ին:',
26
+ min: '{errorKey}ը չի կարող լինել {min}-ից պակաս:',
27
+ max: '{errorKey}ը չի կարող լինել {max}-ից ավելին:',
28
+ range: '{errorKey}ը պետք է լինի {min} և {max} միջև:',
29
+ },
30
+ array: {
31
+ len: '{errorKey}ը պետք է լինի ճիշտ {len} երկարություն:',
32
+ min: '{errorKey}ը չի կարող լինել {min}-ից պակաս երկարությամբ:',
33
+ max: '{errorKey}ը չի կարող լինել {max}-ից ավել երկարությամբ:',
34
+ range: '{errorKey}ը պետք է լինի {min} և {max} երկարության միջև:',
35
+ },
36
+ pattern: {
37
+ mismatch: '{errorKey}ը չի համապատասխանում {pattern} օրինաչափությանը:',
38
+ },
36
39
  },
37
40
  },
38
41
  };
@@ -1,115 +1,124 @@
1
1
  declare const _default: {
2
2
  en: {
3
- serverError: string;
4
- globalError: string;
5
- validateMessages: {
6
- default: string;
7
- required: string;
8
- email: string;
9
- password: string;
10
- enum: string;
11
- whitespace: string;
12
- date: {
13
- format: string;
14
- parse: string;
15
- invalid: string;
16
- };
17
- string: {
18
- len: string;
19
- min: string;
20
- max: string;
21
- range: string;
22
- };
23
- number: {
24
- len: string;
25
- min: string;
26
- max: string;
27
- range: string;
28
- };
29
- array: {
30
- len: string;
31
- min: string;
32
- max: string;
33
- range: string;
34
- };
35
- pattern: {
36
- mismatch: string;
3
+ form: {
4
+ serverError: string;
5
+ globalError: string;
6
+ validateMessages: {
7
+ default: string;
8
+ required: string;
9
+ email: string;
10
+ password: string;
11
+ enum: string;
12
+ whitespace: string;
13
+ phone: string;
14
+ date: {
15
+ format: string;
16
+ parse: string;
17
+ invalid: string;
18
+ };
19
+ string: {
20
+ len: string;
21
+ min: string;
22
+ max: string;
23
+ range: string;
24
+ };
25
+ number: {
26
+ len: string;
27
+ min: string;
28
+ max: string;
29
+ range: string;
30
+ };
31
+ array: {
32
+ len: string;
33
+ min: string;
34
+ max: string;
35
+ range: string;
36
+ };
37
+ pattern: {
38
+ mismatch: string;
39
+ };
37
40
  };
38
41
  };
39
42
  };
40
43
  hy: {
41
- serverError: string;
42
- globalError: string;
43
- validateMessages: {
44
- default: string;
45
- required: string;
46
- email: string;
47
- password: string;
48
- enum: string;
49
- whitespace: string;
50
- date: {
51
- format: string;
52
- parse: string;
53
- invalid: string;
54
- };
55
- string: {
56
- len: string;
57
- min: string;
58
- max: string;
59
- range: string;
60
- };
61
- number: {
62
- len: string;
63
- min: string;
64
- max: string;
65
- range: string;
66
- };
67
- array: {
68
- len: string;
69
- min: string;
70
- max: string;
71
- range: string;
72
- };
73
- pattern: {
74
- mismatch: string;
44
+ form: {
45
+ serverError: string;
46
+ globalError: string;
47
+ validateMessages: {
48
+ default: string;
49
+ required: string;
50
+ email: string;
51
+ password: string;
52
+ enum: string;
53
+ whitespace: string;
54
+ phone: string;
55
+ date: {
56
+ format: string;
57
+ parse: string;
58
+ invalid: string;
59
+ };
60
+ string: {
61
+ len: string;
62
+ min: string;
63
+ max: string;
64
+ range: string;
65
+ };
66
+ number: {
67
+ len: string;
68
+ min: string;
69
+ max: string;
70
+ range: string;
71
+ };
72
+ array: {
73
+ len: string;
74
+ min: string;
75
+ max: string;
76
+ range: string;
77
+ };
78
+ pattern: {
79
+ mismatch: string;
80
+ };
75
81
  };
76
82
  };
77
83
  };
78
84
  ru: {
79
- serverError: string;
80
- globalError: string;
81
- validateMessages: {
82
- default: string;
83
- required: string;
84
- email: string;
85
- password: string;
86
- enum: string;
87
- whitespace: string;
88
- date: {
89
- format: string;
90
- parse: string;
91
- invalid: string;
92
- };
93
- string: {
94
- len: string;
95
- min: string;
96
- max: string;
97
- range: string;
98
- };
99
- number: {
100
- len: string;
101
- min: string;
102
- max: string;
103
- range: string;
104
- };
105
- array: {
106
- len: string;
107
- min: string;
108
- max: string;
109
- range: string;
110
- };
111
- pattern: {
112
- mismatch: string;
85
+ form: {
86
+ serverError: string;
87
+ globalError: string;
88
+ validateMessages: {
89
+ default: string;
90
+ required: string;
91
+ email: string;
92
+ password: string;
93
+ enum: string;
94
+ whitespace: string;
95
+ phone: string;
96
+ date: {
97
+ format: string;
98
+ parse: string;
99
+ invalid: string;
100
+ };
101
+ string: {
102
+ len: string;
103
+ min: string;
104
+ max: string;
105
+ range: string;
106
+ };
107
+ number: {
108
+ len: string;
109
+ min: string;
110
+ max: string;
111
+ range: string;
112
+ };
113
+ array: {
114
+ len: string;
115
+ min: string;
116
+ max: string;
117
+ range: string;
118
+ };
119
+ pattern: {
120
+ mismatch: string;
121
+ };
113
122
  };
114
123
  };
115
124
  };
@@ -1,38 +1,41 @@
1
1
  declare const _default: {
2
- serverError: string;
3
- globalError: string;
4
- validateMessages: {
5
- default: string;
6
- required: string;
7
- email: string;
8
- password: string;
9
- enum: string;
10
- whitespace: string;
11
- date: {
12
- format: string;
13
- parse: string;
14
- invalid: string;
15
- };
16
- string: {
17
- len: string;
18
- min: string;
19
- max: string;
20
- range: string;
21
- };
22
- number: {
23
- len: string;
24
- min: string;
25
- max: string;
26
- range: string;
27
- };
28
- array: {
29
- len: string;
30
- min: string;
31
- max: string;
32
- range: string;
33
- };
34
- pattern: {
35
- mismatch: string;
2
+ form: {
3
+ serverError: string;
4
+ globalError: string;
5
+ validateMessages: {
6
+ default: string;
7
+ required: string;
8
+ email: string;
9
+ password: string;
10
+ enum: string;
11
+ whitespace: string;
12
+ phone: string;
13
+ date: {
14
+ format: string;
15
+ parse: string;
16
+ invalid: string;
17
+ };
18
+ string: {
19
+ len: string;
20
+ min: string;
21
+ max: string;
22
+ range: string;
23
+ };
24
+ number: {
25
+ len: string;
26
+ min: string;
27
+ max: string;
28
+ range: string;
29
+ };
30
+ array: {
31
+ len: string;
32
+ min: string;
33
+ max: string;
34
+ range: string;
35
+ };
36
+ pattern: {
37
+ mismatch: string;
38
+ };
36
39
  };
37
40
  };
38
41
  };
@@ -1,38 +1,41 @@
1
1
  export default {
2
- serverError: 'Упс! Возникла проблема с администрированием сайта.',
3
- globalError: 'Пожалуйста, проверьте обязательные поля и подтвердите еще раз.',
4
- validateMessages: {
5
- default: 'Ошибка валидации для поля {errorKey}',
6
- required: 'Пожалуйста, введите ваш {errorKey}',
7
- email: 'Пожалуйста, введите действительный адрес электронной почты.',
8
- password: 'Пароль должен содержать строчные и заглавные буквы, цифру и быть не менее 8 символов.',
9
- enum: '{errorKey} должен быть одним из [{enum}]',
10
- whitespace: '{errorKey} не может быть пустым',
11
- date: {
12
- format: '{errorKey} имеет недопустимый формат даты',
13
- parse: '{errorKey} не удалось преобразовать в дату',
14
- invalid: '{errorKey} является недопустимой датой',
15
- },
16
- string: {
17
- len: '{errorKey} должен содержать ровно {len} символов',
18
- min: '{errorKey} должен содержать как минимум {min} символов',
19
- max: '{errorKey} не может содержать больше {max} символов',
20
- range: '{errorKey} должен содержать от {min} до {max} символов',
21
- },
22
- number: {
23
- len: '{errorKey} должен быть равен {len}',
24
- min: '{errorKey} не может быть меньше {min}',
25
- max: '{errorKey} не может быть больше {max}',
26
- range: '{errorKey} должен быть между {min} и {max}',
27
- },
28
- array: {
29
- len: '{errorKey} должен содержать ровно {len} элементов',
30
- min: '{errorKey} не может содержать менее {min} элементов',
31
- max: '{errorKey} не может содержать более {max} элементов',
32
- range: '{errorKey} должен содержать от {min} до {max} элементов',
33
- },
34
- pattern: {
35
- mismatch: '{errorKey} не соответствует шаблону {pattern}',
2
+ form: {
3
+ serverError: 'Упс! Возникла проблема с администрированием сайта.',
4
+ globalError: 'Пожалуйста, проверьте обязательные поля и подтвердите еще раз.',
5
+ validateMessages: {
6
+ default: 'Ошибка валидации для поля {errorKey}.',
7
+ required: 'Пожалуйста, введите ваш {errorKey}.',
8
+ email: 'Пожалуйста, введите действительный адрес электронной почты.',
9
+ password: 'Пароль должен состоять не менее чем из 8 символов.',
10
+ enum: '{errorKey} должен быть одним из [{enum}].',
11
+ whitespace: '{errorKey} не может быть пустым.',
12
+ phone: 'Пожалуйста, введите действительный {errorKey}.',
13
+ date: {
14
+ format: '{errorKey} имеет недопустимый формат даты.',
15
+ parse: '{errorKey} не удалось преобразовать в дату.',
16
+ invalid: '{errorKey} является недопустимой датой.',
17
+ },
18
+ string: {
19
+ len: '{errorKey} должен содержать ровно {len} символов.',
20
+ min: '{errorKey} должен содержать как минимум {min} символов.',
21
+ max: '{errorKey} не может содержать больше {max} символов.',
22
+ range: '{errorKey} должен содержать от {min} до {max} символов.',
23
+ },
24
+ number: {
25
+ len: '{errorKey} должен быть равен {len}.',
26
+ min: '{errorKey} не может быть меньше {min}.',
27
+ max: '{errorKey} не может быть больше {max}.',
28
+ range: '{errorKey} должен быть между {min} и {max}.',
29
+ },
30
+ array: {
31
+ len: '{errorKey} должен содержать ровно {len} элементов.',
32
+ min: '{errorKey} не может содержать менее {min} элементов.',
33
+ max: '{errorKey} не может содержать более {max} элементов.',
34
+ range: '{errorKey} должен содержать от {min} до {max} элементов.',
35
+ },
36
+ pattern: {
37
+ mismatch: '{errorKey} не соответствует шаблону {pattern}.',
38
+ },
36
39
  },
37
40
  },
38
41
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weareconceptstudio/form",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Concept Studio Form",
5
5
  "author": "Concept Studio",
6
6
  "license": "ISC",