@juantroconisf/lib 3.2.4 → 3.2.6
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/dist/index.js +3 -3
- package/dist/index.mjs +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -154,7 +154,7 @@ function useValidation() {
|
|
|
154
154
|
const { lang } = useComponentLanguage();
|
|
155
155
|
const getValidation = (value, isTouched, types, errorMessages) => {
|
|
156
156
|
if (!types) return { isValid: true, validationProps: nxError() };
|
|
157
|
-
const items = Object.entries(types),
|
|
157
|
+
const items = Object.entries(types), requiredExist = types?.required !== void 0, isRequired = requiredExist ? types.required : false;
|
|
158
158
|
if (value === "" && !isRequired || !isTouched)
|
|
159
159
|
return { isValid: true, validationProps: nxError() };
|
|
160
160
|
const validations = items.map(([name, opts]) => {
|
|
@@ -199,7 +199,6 @@ function useFormChange({
|
|
|
199
199
|
isInvalid: false,
|
|
200
200
|
errorMessage: ""
|
|
201
201
|
};
|
|
202
|
-
if (requirements === void 0) return props;
|
|
203
202
|
const [ui] = [
|
|
204
203
|
{
|
|
205
204
|
ref: errors2,
|
|
@@ -219,10 +218,11 @@ function useFormChange({
|
|
|
219
218
|
item.ref.current = handleNestedChange({
|
|
220
219
|
state: item.ref.current,
|
|
221
220
|
id,
|
|
222
|
-
value: req.isValid
|
|
221
|
+
value: !req.isValid
|
|
223
222
|
});
|
|
224
223
|
return req;
|
|
225
224
|
});
|
|
225
|
+
if (requirements === void 0) return props;
|
|
226
226
|
return {
|
|
227
227
|
...props,
|
|
228
228
|
isInvalid: !ui.isValid,
|
package/dist/index.mjs
CHANGED
|
@@ -135,7 +135,7 @@ function useValidation() {
|
|
|
135
135
|
const { lang } = useComponentLanguage();
|
|
136
136
|
const getValidation = (value, isTouched, types, errorMessages) => {
|
|
137
137
|
if (!types) return { isValid: true, validationProps: nxError() };
|
|
138
|
-
const items = Object.entries(types),
|
|
138
|
+
const items = Object.entries(types), requiredExist = types?.required !== void 0, isRequired = requiredExist ? types.required : false;
|
|
139
139
|
if (value === "" && !isRequired || !isTouched)
|
|
140
140
|
return { isValid: true, validationProps: nxError() };
|
|
141
141
|
const validations = items.map(([name, opts]) => {
|
|
@@ -180,7 +180,6 @@ function useFormChange({
|
|
|
180
180
|
isInvalid: false,
|
|
181
181
|
errorMessage: ""
|
|
182
182
|
};
|
|
183
|
-
if (requirements === void 0) return props;
|
|
184
183
|
const [ui] = [
|
|
185
184
|
{
|
|
186
185
|
ref: errors2,
|
|
@@ -200,10 +199,11 @@ function useFormChange({
|
|
|
200
199
|
item.ref.current = handleNestedChange({
|
|
201
200
|
state: item.ref.current,
|
|
202
201
|
id,
|
|
203
|
-
value: req.isValid
|
|
202
|
+
value: !req.isValid
|
|
204
203
|
});
|
|
205
204
|
return req;
|
|
206
205
|
});
|
|
206
|
+
if (requirements === void 0) return props;
|
|
207
207
|
return {
|
|
208
208
|
...props,
|
|
209
209
|
isInvalid: !ui.isValid,
|