@juantroconisf/lib 3.2.5 → 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 +2 -2
- package/dist/index.mjs +2 -2
- 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]) => {
|
|
@@ -218,7 +218,7 @@ function useFormChange({
|
|
|
218
218
|
item.ref.current = handleNestedChange({
|
|
219
219
|
state: item.ref.current,
|
|
220
220
|
id,
|
|
221
|
-
value: req.isValid
|
|
221
|
+
value: !req.isValid
|
|
222
222
|
});
|
|
223
223
|
return req;
|
|
224
224
|
});
|
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]) => {
|
|
@@ -199,7 +199,7 @@ function useFormChange({
|
|
|
199
199
|
item.ref.current = handleNestedChange({
|
|
200
200
|
state: item.ref.current,
|
|
201
201
|
id,
|
|
202
|
-
value: req.isValid
|
|
202
|
+
value: !req.isValid
|
|
203
203
|
});
|
|
204
204
|
return req;
|
|
205
205
|
});
|