@onesy/ui-react 1.0.72 → 1.0.73

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/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license UiReact v1.0.72
1
+ /** @license UiReact v1.0.73
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -4,6 +4,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
4
4
  import React from 'react';
5
5
  import { capitalize, copy, is, setObjectValue } from '@onesy/utils';
6
6
  import validateModel from './validate';
7
+ import { useOnesyTheme } from 'packages/style-react/build';
7
8
  const useForm = props => {
8
9
  const {
9
10
  values: values_ = {},
@@ -13,6 +14,8 @@ const useForm = props => {
13
14
  valueDefault,
14
15
  validDefault
15
16
  } = props;
17
+ const theme = useOnesyTheme();
18
+ const l = theme.l;
16
19
  const [form, setForm] = React.useState({
17
20
  value: valueDefault !== undefined ? valueDefault : {},
18
21
  values: copy(values_ || {}),
@@ -77,13 +80,15 @@ const useForm = props => {
77
80
  // Validate the property
78
81
  if (property.required && property.value === undefined) {
79
82
  const name = is('function', property.propertyNameUpdate) ? property.propertyNameUpdate(property.name) : property.capitalize !== false ? capitalize(property.name) : property.name;
80
- property.error = `${name} is required`;
83
+ property.error = `${name} ${l('is required')}`;
81
84
  } else {
82
85
  property.error = undefined;
83
86
 
84
87
  // validations
85
88
  try {
86
- await validateModel(property, property_, formNew);
89
+ await validateModel(property, property_, formNew, {
90
+ l
91
+ });
87
92
  } catch (error) {
88
93
  property.error = error.message;
89
94
  }
@@ -128,13 +133,15 @@ const useForm = props => {
128
133
  // Validate the property
129
134
  if (property.required && property.value === undefined) {
130
135
  const name = is('function', property.propertyNameUpdate) ? property.propertyNameUpdate(property.name) : property.capitalize !== false ? capitalize(property.name) : property.name;
131
- property.error = `${name} is required`;
136
+ property.error = `${name} ${l('is required')}`;
132
137
  } else {
133
138
  property.error = undefined;
134
139
 
135
140
  // validations
136
141
  try {
137
- await validateModel(property, item, formNew);
142
+ await validateModel(property, item, formNew, {
143
+ l
144
+ });
138
145
  property.error = undefined;
139
146
  } catch (error) {
140
147
  property.error = error.message;
@@ -18,6 +18,7 @@ const validate = async (model, property, form, options_) => {
18
18
  uriDecode: true,
19
19
  parse: true
20
20
  });
21
+ const l = options?.l || (item => item);
21
22
  const name = is('function', model.propertyNameUpdate) ? model.propertyNameUpdate(model.name) : model.capitalize !== false ? capitalize(model.name) : model.name;
22
23
  const value = model.value;
23
24
 
@@ -27,7 +28,7 @@ const validate = async (model, property, form, options_) => {
27
28
  // required
28
29
  if (model.required) {
29
30
  const response = value;
30
- if (response === undefined) onValidateError(options, model, model.messages?.required || `${name} is required`);
31
+ if (response === undefined) onValidateError(options, model, model.messages?.required || `${name} ${l('is required')}`);
31
32
  }
32
33
 
33
34
  // only validate
@@ -42,7 +43,7 @@ const validate = async (model, property, form, options_) => {
42
43
  const itemType = item?.type || item;
43
44
  const itemOptions = item?.options || undefined;
44
45
  const response = is(itemType, value, itemOptions);
45
- if (!response) onValidateError(options, model, model.messages?.is || `${name} has to be a valid ${cleanValue(itemType)}`);
46
+ if (!response) onValidateError(options, model, model.messages?.is || `${name} ${l('has to be a valid')} ${cleanValue(l(itemType))}`);
46
47
  }
47
48
  }
48
49
 
@@ -53,7 +54,7 @@ const validate = async (model, property, form, options_) => {
53
54
  const itemType = item?.type || item;
54
55
  const itemOptions = item?.options || undefined;
55
56
  const response = isValid(itemType, value, itemOptions);
56
- if (!response) onValidateError(options, model, model.messages?.isValid || `${name} has to be a valid ${cleanValue(itemType)}`);
57
+ if (!response) onValidateError(options, model, model.messages?.isValid || `${name} ${l('has to be a valid')} ${cleanValue(l(itemType))}`);
57
58
  }
58
59
  }
59
60
 
@@ -68,7 +69,7 @@ const validate = async (model, property, form, options_) => {
68
69
  return is(itemType, valueItem, itemOptions);
69
70
  });
70
71
  });
71
- if (!response) onValidateError(options, model, model.messages?.of || `${name} items have to be one of ${of_.map(item => item?.type || item).join(', ')}`);
72
+ if (!response) onValidateError(options, model, model.messages?.of || `${name} ${l('items have to be one of')} ${of_.map(item => l(item?.type || item)).join(', ')}`);
72
73
  }
73
74
  }
74
75
 
@@ -83,32 +84,32 @@ const validate = async (model, property, form, options_) => {
83
84
  return isValid(itemType, valueItem, itemOptions);
84
85
  });
85
86
  });
86
- if (!response) onValidateError(options, model, model.messages?.ofValid || `${name} items have to be one of valid ${ofValid.map(item => item?.type || item).join(', ')}`);
87
+ if (!response) onValidateError(options, model, model.messages?.ofValid || `${name} ${l('items have to be one of valid')} ${ofValid.map(item => l(item?.type || item)).join(', ')}`);
87
88
  }
88
89
  }
89
90
 
90
91
  // equal
91
92
  if (model.equal !== undefined) {
92
93
  const response = value === model.equal;
93
- if (!response) onValidateError(options, model, model.messages?.equal || `${name} has to be equal to ${stringify(model.equal)}`);
94
+ if (!response) onValidateError(options, model, model.messages?.equal || `${name} ${l('has to be equal to')} ${stringify(model.equal)}`);
94
95
  }
95
96
 
96
97
  // not equal
97
98
  if (model.notEqual !== undefined) {
98
99
  const response = value !== model.equal;
99
- if (!response) onValidateError(options, model, model.messages?.notEqual || `${name} has to not be equal to ${stringify(model.equal)}`);
100
+ if (!response) onValidateError(options, model, model.messages?.notEqual || `${name} ${l('has to not be equal to')} ${stringify(model.equal)}`);
100
101
  }
101
102
 
102
103
  // equal deep
103
104
  if (model.equalDeep !== undefined) {
104
105
  const response = equalDeep(value, model.equalDeep);
105
- if (!response) onValidateError(options, model, model.messages?.equalDeep || `${name} has to be equal to ${stringify(model.equalDeep)}`);
106
+ if (!response) onValidateError(options, model, model.messages?.equalDeep || `${name} ${l('has to be equal to')} ${stringify(model.equalDeep)}`);
106
107
  }
107
108
 
108
109
  // not equal deep
109
110
  if (model.notEqualDeep !== undefined) {
110
111
  const response = !equalDeep(value, model.notEqualDeep);
111
- if (!response) onValidateError(options, model, model.messages?.notEqualDeep || `${name} has to not be equal to ${stringify(model.notEqualDeep)}`);
112
+ if (!response) onValidateError(options, model, model.messages?.notEqualDeep || `${name} ${l('has to not be equal to')} ${stringify(model.notEqualDeep)}`);
112
113
  }
113
114
 
114
115
  // some
@@ -116,10 +117,10 @@ const validate = async (model, property, form, options_) => {
116
117
  let response;
117
118
  if (is('string', value)) {
118
119
  response = !!model.some.find(item => equalDeep(value, item));
119
- if (!response) onValidateError(options, model, model.messages?.some || `${name} has to be one of ${model.some.map(item => stringify(item)).join(', ')}`);
120
+ if (!response) onValidateError(options, model, model.messages?.some || `${name} ${l('has to be one of')} ${model.some.map(item => stringify(item)).join(', ')}`);
120
121
  } else if (is('array', value)) {
121
122
  response = value.some(item => !!model.some.find(item_ => equalDeep(item, item_)));
122
- if (!response) onValidateError(options, model, model.messages?.some || `${name} has to include some of ${model.some.map(item => stringify(item)).join(', ')}`);
123
+ if (!response) onValidateError(options, model, model.messages?.some || `${name} ${l('has to include some of')} ${model.some.map(item => stringify(item)).join(', ')}`);
123
124
  }
124
125
  }
125
126
 
@@ -130,10 +131,10 @@ const validate = async (model, property, form, options_) => {
130
131
  let response;
131
132
  if (is('string', value)) {
132
133
  response = !!every.find(item => equalDeep(value, item));
133
- if (!response) onValidateError(options, model, model.messages?.in || model.messages?.every || `${name} has to be one of ${every.map(item => stringify(item)).join(', ')}`);
134
+ if (!response) onValidateError(options, model, model.messages?.in || model.messages?.every || `${name} ${l('has to be one of')} ${every.map(item => stringify(item)).join(', ')}`);
134
135
  } else if (is('array', value)) {
135
136
  response = value.every(item => !!every.find(item_ => equalDeep(item, item_)));
136
- if (!response) onValidateError(options, model, model.messages?.in || model.messages?.every || `${name} has to include one of ${every.map(item => stringify(item)).join(', ')}`);
137
+ if (!response) onValidateError(options, model, model.messages?.in || model.messages?.every || `${name} ${l('has to include one of')} ${every.map(item => stringify(item)).join(', ')}`);
137
138
  }
138
139
  }
139
140
 
@@ -142,7 +143,7 @@ const validate = async (model, property, form, options_) => {
142
143
  const allowed = model.properties;
143
144
  const keys = Object.keys(value);
144
145
  const response = keys.every(item => allowed.includes(item));
145
- if (!response) onValidateError(options, model, model.messages?.properties || `${name} allowed properties are ${allowed.join(', ')}`);
146
+ if (!response) onValidateError(options, model, model.messages?.properties || `${name} ${l('allowed properties are')} ${allowed.join(', ')}`);
146
147
  }
147
148
 
148
149
  // not properties
@@ -150,7 +151,7 @@ const validate = async (model, property, form, options_) => {
150
151
  const notAllowed = model.notProperties;
151
152
  const keys = Object.keys(value);
152
153
  const response = keys.every(item => !notAllowed.includes(item));
153
- if (!response) onValidateError(options, model, model.messages?.notProperties || `${name} includes not allowed property. Not allowed properties are ${notAllowed.join(', ')}`);
154
+ if (!response) onValidateError(options, model, model.messages?.notProperties || `${name} ${l('includes not allowed property')}. ${l('Not allowed properties are')} ${notAllowed.join(', ')}`);
154
155
  }
155
156
 
156
157
  // min
@@ -169,15 +170,15 @@ const validate = async (model, property, form, options_) => {
169
170
  }
170
171
  if (is('number', model.min)) {
171
172
  const response = length >= model.min;
172
- if (!response) onValidateError(options, model, model.messages?.min || `${name} has to be minimum ${model.min}`);
173
+ if (!response) onValidateError(options, model, model.messages?.min || `${name} ${l('has to be minimum')} ${model.min}`);
173
174
  }
174
175
  if (is('number', model.max)) {
175
176
  const response = length <= model.max;
176
- if (!response) onValidateError(options, model, model.messages?.max || `${name} can be maximum ${model.max}`);
177
+ if (!response) onValidateError(options, model, model.messages?.max || `${name} ${l('can be maximum')} ${model.max}`);
177
178
  }
178
179
  if (is('number', model.length)) {
179
180
  const response = length === model.length;
180
- if (!response) onValidateError(options, model, model.messages?.length || `${name} has to be exactly ${model.length} in length/size`);
181
+ if (!response) onValidateError(options, model, model.messages?.length || `${name} ${l('has to be exactly')} ${model.length} ${l('in length/size')}`);
181
182
  }
182
183
  }
183
184
 
@@ -193,7 +194,7 @@ const validate = async (model, property, form, options_) => {
193
194
  options
194
195
  });
195
196
  if (response !== undefined) {
196
- if (!response) throw new ValidationError(`${name} is invalid`);
197
+ if (!response) throw new ValidationError(`${name} ${l('is invalid')}`);
197
198
  }
198
199
  } catch (error) {
199
200
  const messageValue = error?.message !== undefined ? error.message : error;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onesy/ui-react",
3
- "version": "1.0.72",
3
+ "version": "1.0.73",
4
4
  "description": "UI for React",
5
5
  "repository": "https://github.com/onesy-me/onesy.git",
6
6
  "author": "Lazar <lazareric2@gmail.com>",
@@ -6,8 +6,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const react_1 = __importDefault(require("react"));
7
7
  const utils_1 = require("@onesy/utils");
8
8
  const validate_1 = __importDefault(require("./validate"));
9
+ const build_1 = require("packages/style-react/build");
9
10
  const useForm = (props) => {
10
11
  const { values: values_ = {}, validate: validate_, rerenderOnUpdate = true, autoValidate, valueDefault, validDefault } = props;
12
+ const theme = (0, build_1.useOnesyTheme)();
13
+ const l = theme.l;
11
14
  const [form, setForm] = react_1.default.useState({
12
15
  value: valueDefault !== undefined ? valueDefault : {},
13
16
  values: (0, utils_1.copy)(values_ || {}),
@@ -68,13 +71,13 @@ const useForm = (props) => {
68
71
  // Validate the property
69
72
  if (property.required && property.value === undefined) {
70
73
  const name = (0, utils_1.is)('function', property.propertyNameUpdate) ? property.propertyNameUpdate(property.name) : property.capitalize !== false ? (0, utils_1.capitalize)(property.name) : property.name;
71
- property.error = `${name} is required`;
74
+ property.error = `${name} ${l('is required')}`;
72
75
  }
73
76
  else {
74
77
  property.error = undefined;
75
78
  // validations
76
79
  try {
77
- await (0, validate_1.default)(property, property_, formNew);
80
+ await (0, validate_1.default)(property, property_, formNew, { l });
78
81
  }
79
82
  catch (error) {
80
83
  property.error = error.message;
@@ -119,13 +122,13 @@ const useForm = (props) => {
119
122
  // Validate the property
120
123
  if (property.required && property.value === undefined) {
121
124
  const name = (0, utils_1.is)('function', property.propertyNameUpdate) ? property.propertyNameUpdate(property.name) : property.capitalize !== false ? (0, utils_1.capitalize)(property.name) : property.name;
122
- property.error = `${name} is required`;
125
+ property.error = `${name} ${l('is required')}`;
123
126
  }
124
127
  else {
125
128
  property.error = undefined;
126
129
  // validations
127
130
  try {
128
- await (0, validate_1.default)(property, item, formNew);
131
+ await (0, validate_1.default)(property, item, formNew, { l });
129
132
  property.error = undefined;
130
133
  }
131
134
  catch (error) {
@@ -4,6 +4,7 @@ export type IValidateOptions = {
4
4
  message?: string;
5
5
  uriDecode?: boolean;
6
6
  parse?: boolean;
7
+ l?: any;
7
8
  };
8
9
  export type IValidateModelValueIs = {
9
10
  type?: TIsType;
@@ -23,6 +23,7 @@ exports.onValidateError = onValidateError;
23
23
  const validate = async (model, property, form, options_) => {
24
24
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
25
25
  const options = (0, utils_1.merge)((options_ && (0, is_1.default)('object', options_)) ? options_ : {}, { uriDecode: true, parse: true });
26
+ const l = (options === null || options === void 0 ? void 0 : options.l) || (item => item);
26
27
  const name = (0, is_1.default)('function', model.propertyNameUpdate) ? model.propertyNameUpdate(model.name) : model.capitalize !== false ? (0, utils_1.capitalize)(model.name) : model.name;
27
28
  const value = model.value;
28
29
  // value validate
@@ -31,7 +32,7 @@ const validate = async (model, property, form, options_) => {
31
32
  if (model.required) {
32
33
  const response = value;
33
34
  if (response === undefined)
34
- (0, exports.onValidateError)(options, model, ((_a = model.messages) === null || _a === void 0 ? void 0 : _a.required) || `${name} is required`);
35
+ (0, exports.onValidateError)(options, model, ((_a = model.messages) === null || _a === void 0 ? void 0 : _a.required) || `${name} ${l('is required')}`);
35
36
  }
36
37
  // only validate
37
38
  // if value is not undefined
@@ -46,7 +47,7 @@ const validate = async (model, property, form, options_) => {
46
47
  const itemOptions = (item === null || item === void 0 ? void 0 : item.options) || undefined;
47
48
  const response = (0, is_1.default)(itemType, value, itemOptions);
48
49
  if (!response)
49
- (0, exports.onValidateError)(options, model, ((_b = model.messages) === null || _b === void 0 ? void 0 : _b.is) || `${name} has to be a valid ${(0, utils_1.cleanValue)(itemType)}`);
50
+ (0, exports.onValidateError)(options, model, ((_b = model.messages) === null || _b === void 0 ? void 0 : _b.is) || `${name} ${l('has to be a valid')} ${(0, utils_1.cleanValue)(l(itemType))}`);
50
51
  }
51
52
  }
52
53
  // is valid
@@ -57,7 +58,7 @@ const validate = async (model, property, form, options_) => {
57
58
  const itemOptions = (item === null || item === void 0 ? void 0 : item.options) || undefined;
58
59
  const response = (0, isValid_1.default)(itemType, value, itemOptions);
59
60
  if (!response)
60
- (0, exports.onValidateError)(options, model, ((_c = model.messages) === null || _c === void 0 ? void 0 : _c.isValid) || `${name} has to be a valid ${(0, utils_1.cleanValue)(itemType)}`);
61
+ (0, exports.onValidateError)(options, model, ((_c = model.messages) === null || _c === void 0 ? void 0 : _c.isValid) || `${name} ${l('has to be a valid')} ${(0, utils_1.cleanValue)(l(itemType))}`);
61
62
  }
62
63
  }
63
64
  // of
@@ -72,7 +73,7 @@ const validate = async (model, property, form, options_) => {
72
73
  });
73
74
  });
74
75
  if (!response)
75
- (0, exports.onValidateError)(options, model, ((_d = model.messages) === null || _d === void 0 ? void 0 : _d.of) || `${name} items have to be one of ${of_.map(item => (item === null || item === void 0 ? void 0 : item.type) || item).join(', ')}`);
76
+ (0, exports.onValidateError)(options, model, ((_d = model.messages) === null || _d === void 0 ? void 0 : _d.of) || `${name} ${l('items have to be one of')} ${of_.map(item => l((item === null || item === void 0 ? void 0 : item.type) || item)).join(', ')}`);
76
77
  }
77
78
  }
78
79
  // ofValid
@@ -87,32 +88,32 @@ const validate = async (model, property, form, options_) => {
87
88
  });
88
89
  });
89
90
  if (!response)
90
- (0, exports.onValidateError)(options, model, ((_e = model.messages) === null || _e === void 0 ? void 0 : _e.ofValid) || `${name} items have to be one of valid ${ofValid.map(item => (item === null || item === void 0 ? void 0 : item.type) || item).join(', ')}`);
91
+ (0, exports.onValidateError)(options, model, ((_e = model.messages) === null || _e === void 0 ? void 0 : _e.ofValid) || `${name} ${l('items have to be one of valid')} ${ofValid.map(item => l((item === null || item === void 0 ? void 0 : item.type) || item)).join(', ')}`);
91
92
  }
92
93
  }
93
94
  // equal
94
95
  if (model.equal !== undefined) {
95
96
  const response = value === model.equal;
96
97
  if (!response)
97
- (0, exports.onValidateError)(options, model, ((_f = model.messages) === null || _f === void 0 ? void 0 : _f.equal) || `${name} has to be equal to ${(0, utils_1.stringify)(model.equal)}`);
98
+ (0, exports.onValidateError)(options, model, ((_f = model.messages) === null || _f === void 0 ? void 0 : _f.equal) || `${name} ${l('has to be equal to')} ${(0, utils_1.stringify)(model.equal)}`);
98
99
  }
99
100
  // not equal
100
101
  if (model.notEqual !== undefined) {
101
102
  const response = value !== model.equal;
102
103
  if (!response)
103
- (0, exports.onValidateError)(options, model, ((_g = model.messages) === null || _g === void 0 ? void 0 : _g.notEqual) || `${name} has to not be equal to ${(0, utils_1.stringify)(model.equal)}`);
104
+ (0, exports.onValidateError)(options, model, ((_g = model.messages) === null || _g === void 0 ? void 0 : _g.notEqual) || `${name} ${l('has to not be equal to')} ${(0, utils_1.stringify)(model.equal)}`);
104
105
  }
105
106
  // equal deep
106
107
  if (model.equalDeep !== undefined) {
107
108
  const response = (0, utils_1.equalDeep)(value, model.equalDeep);
108
109
  if (!response)
109
- (0, exports.onValidateError)(options, model, ((_h = model.messages) === null || _h === void 0 ? void 0 : _h.equalDeep) || `${name} has to be equal to ${(0, utils_1.stringify)(model.equalDeep)}`);
110
+ (0, exports.onValidateError)(options, model, ((_h = model.messages) === null || _h === void 0 ? void 0 : _h.equalDeep) || `${name} ${l('has to be equal to')} ${(0, utils_1.stringify)(model.equalDeep)}`);
110
111
  }
111
112
  // not equal deep
112
113
  if (model.notEqualDeep !== undefined) {
113
114
  const response = !(0, utils_1.equalDeep)(value, model.notEqualDeep);
114
115
  if (!response)
115
- (0, exports.onValidateError)(options, model, ((_j = model.messages) === null || _j === void 0 ? void 0 : _j.notEqualDeep) || `${name} has to not be equal to ${(0, utils_1.stringify)(model.notEqualDeep)}`);
116
+ (0, exports.onValidateError)(options, model, ((_j = model.messages) === null || _j === void 0 ? void 0 : _j.notEqualDeep) || `${name} ${l('has to not be equal to')} ${(0, utils_1.stringify)(model.notEqualDeep)}`);
116
117
  }
117
118
  // some
118
119
  if ((0, is_1.default)('array', model.some)) {
@@ -120,12 +121,12 @@ const validate = async (model, property, form, options_) => {
120
121
  if ((0, is_1.default)('string', value)) {
121
122
  response = !!model.some.find(item => (0, utils_1.equalDeep)(value, item));
122
123
  if (!response)
123
- (0, exports.onValidateError)(options, model, ((_k = model.messages) === null || _k === void 0 ? void 0 : _k.some) || `${name} has to be one of ${model.some.map(item => (0, utils_1.stringify)(item)).join(', ')}`);
124
+ (0, exports.onValidateError)(options, model, ((_k = model.messages) === null || _k === void 0 ? void 0 : _k.some) || `${name} ${l('has to be one of')} ${model.some.map(item => (0, utils_1.stringify)(item)).join(', ')}`);
124
125
  }
125
126
  else if ((0, is_1.default)('array', value)) {
126
127
  response = value.some(item => !!model.some.find(item_ => (0, utils_1.equalDeep)(item, item_)));
127
128
  if (!response)
128
- (0, exports.onValidateError)(options, model, ((_l = model.messages) === null || _l === void 0 ? void 0 : _l.some) || `${name} has to include some of ${model.some.map(item => (0, utils_1.stringify)(item)).join(', ')}`);
129
+ (0, exports.onValidateError)(options, model, ((_l = model.messages) === null || _l === void 0 ? void 0 : _l.some) || `${name} ${l('has to include some of')} ${model.some.map(item => (0, utils_1.stringify)(item)).join(', ')}`);
129
130
  }
130
131
  }
131
132
  // in
@@ -136,12 +137,12 @@ const validate = async (model, property, form, options_) => {
136
137
  if ((0, is_1.default)('string', value)) {
137
138
  response = !!every.find(item => (0, utils_1.equalDeep)(value, item));
138
139
  if (!response)
139
- (0, exports.onValidateError)(options, model, ((_m = model.messages) === null || _m === void 0 ? void 0 : _m.in) || ((_o = model.messages) === null || _o === void 0 ? void 0 : _o.every) || `${name} has to be one of ${every.map(item => (0, utils_1.stringify)(item)).join(', ')}`);
140
+ (0, exports.onValidateError)(options, model, ((_m = model.messages) === null || _m === void 0 ? void 0 : _m.in) || ((_o = model.messages) === null || _o === void 0 ? void 0 : _o.every) || `${name} ${l('has to be one of')} ${every.map(item => (0, utils_1.stringify)(item)).join(', ')}`);
140
141
  }
141
142
  else if ((0, is_1.default)('array', value)) {
142
143
  response = value.every(item => !!every.find(item_ => (0, utils_1.equalDeep)(item, item_)));
143
144
  if (!response)
144
- (0, exports.onValidateError)(options, model, ((_p = model.messages) === null || _p === void 0 ? void 0 : _p.in) || ((_q = model.messages) === null || _q === void 0 ? void 0 : _q.every) || `${name} has to include one of ${every.map(item => (0, utils_1.stringify)(item)).join(', ')}`);
145
+ (0, exports.onValidateError)(options, model, ((_p = model.messages) === null || _p === void 0 ? void 0 : _p.in) || ((_q = model.messages) === null || _q === void 0 ? void 0 : _q.every) || `${name} ${l('has to include one of')} ${every.map(item => (0, utils_1.stringify)(item)).join(', ')}`);
145
146
  }
146
147
  }
147
148
  // properties
@@ -150,7 +151,7 @@ const validate = async (model, property, form, options_) => {
150
151
  const keys = Object.keys(value);
151
152
  const response = keys.every(item => allowed.includes(item));
152
153
  if (!response)
153
- (0, exports.onValidateError)(options, model, ((_r = model.messages) === null || _r === void 0 ? void 0 : _r.properties) || `${name} allowed properties are ${allowed.join(', ')}`);
154
+ (0, exports.onValidateError)(options, model, ((_r = model.messages) === null || _r === void 0 ? void 0 : _r.properties) || `${name} ${l('allowed properties are')} ${allowed.join(', ')}`);
154
155
  }
155
156
  // not properties
156
157
  if ((0, is_1.default)('array', model.notProperties)) {
@@ -158,7 +159,7 @@ const validate = async (model, property, form, options_) => {
158
159
  const keys = Object.keys(value);
159
160
  const response = keys.every(item => !notAllowed.includes(item));
160
161
  if (!response)
161
- (0, exports.onValidateError)(options, model, ((_s = model.messages) === null || _s === void 0 ? void 0 : _s.notProperties) || `${name} includes not allowed property. Not allowed properties are ${notAllowed.join(', ')}`);
162
+ (0, exports.onValidateError)(options, model, ((_s = model.messages) === null || _s === void 0 ? void 0 : _s.notProperties) || `${name} ${l('includes not allowed property')}. ${l('Not allowed properties are')} ${notAllowed.join(', ')}`);
162
163
  }
163
164
  // min
164
165
  // max
@@ -181,17 +182,17 @@ const validate = async (model, property, form, options_) => {
181
182
  if ((0, is_1.default)('number', model.min)) {
182
183
  const response = length >= model.min;
183
184
  if (!response)
184
- (0, exports.onValidateError)(options, model, ((_t = model.messages) === null || _t === void 0 ? void 0 : _t.min) || `${name} has to be minimum ${model.min}`);
185
+ (0, exports.onValidateError)(options, model, ((_t = model.messages) === null || _t === void 0 ? void 0 : _t.min) || `${name} ${l('has to be minimum')} ${model.min}`);
185
186
  }
186
187
  if ((0, is_1.default)('number', model.max)) {
187
188
  const response = length <= model.max;
188
189
  if (!response)
189
- (0, exports.onValidateError)(options, model, ((_u = model.messages) === null || _u === void 0 ? void 0 : _u.max) || `${name} can be maximum ${model.max}`);
190
+ (0, exports.onValidateError)(options, model, ((_u = model.messages) === null || _u === void 0 ? void 0 : _u.max) || `${name} ${l('can be maximum')} ${model.max}`);
190
191
  }
191
192
  if ((0, is_1.default)('number', model.length)) {
192
193
  const response = length === model.length;
193
194
  if (!response)
194
- (0, exports.onValidateError)(options, model, ((_v = model.messages) === null || _v === void 0 ? void 0 : _v.length) || `${name} has to be exactly ${model.length} in length/size`);
195
+ (0, exports.onValidateError)(options, model, ((_v = model.messages) === null || _v === void 0 ? void 0 : _v.length) || `${name} ${l('has to be exactly')} ${model.length} ${l('in length/size')}`);
195
196
  }
196
197
  }
197
198
  // method
@@ -207,7 +208,7 @@ const validate = async (model, property, form, options_) => {
207
208
  });
208
209
  if (response !== undefined) {
209
210
  if (!response)
210
- throw new errors_1.ValidationError(`${name} is invalid`);
211
+ throw new errors_1.ValidationError(`${name} ${l('is invalid')}`);
211
212
  }
212
213
  }
213
214
  catch (error) {