@juantroconisf/lib 2.2.10 → 2.3.0
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 -1
- package/dist/index.mjs +3 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -153,7 +153,7 @@ function useComponentLanguage() {
|
|
|
153
153
|
function useValidation() {
|
|
154
154
|
const { lang } = useComponentLanguage();
|
|
155
155
|
const getValidation = (value, isTouched, types, errorMessages) => {
|
|
156
|
-
const items = Object.entries(types),
|
|
156
|
+
const items = Object.entries(types), requiredIndex = items.findIndex(([key]) => key === "required"), isRequired = requiredIndex === -1 ? false : items[requiredIndex][1];
|
|
157
157
|
if (isRequired && !isTouched)
|
|
158
158
|
return {
|
|
159
159
|
isValid: true,
|
|
@@ -169,6 +169,8 @@ function useValidation() {
|
|
|
169
169
|
isValid: true,
|
|
170
170
|
msg: ""
|
|
171
171
|
};
|
|
172
|
+
if (!isValid && value === "" && !isRequired)
|
|
173
|
+
return { isValid: true, validationProps: nxError() };
|
|
172
174
|
return {
|
|
173
175
|
isValid,
|
|
174
176
|
validationProps: nxError(!isValid, msg)
|
package/dist/index.mjs
CHANGED
|
@@ -135,7 +135,7 @@ function useComponentLanguage() {
|
|
|
135
135
|
function useValidation() {
|
|
136
136
|
const { lang } = useComponentLanguage();
|
|
137
137
|
const getValidation = (value, isTouched, types, errorMessages) => {
|
|
138
|
-
const items = Object.entries(types),
|
|
138
|
+
const items = Object.entries(types), requiredIndex = items.findIndex(([key]) => key === "required"), isRequired = requiredIndex === -1 ? false : items[requiredIndex][1];
|
|
139
139
|
if (isRequired && !isTouched)
|
|
140
140
|
return {
|
|
141
141
|
isValid: true,
|
|
@@ -151,6 +151,8 @@ function useValidation() {
|
|
|
151
151
|
isValid: true,
|
|
152
152
|
msg: ""
|
|
153
153
|
};
|
|
154
|
+
if (!isValid && value === "" && !isRequired)
|
|
155
|
+
return { isValid: true, validationProps: nxError() };
|
|
154
156
|
return {
|
|
155
157
|
isValid,
|
|
156
158
|
validationProps: nxError(!isValid, msg)
|