@juantroconisf/lib 2.2.0 → 2.2.1
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.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -1
- package/dist/index.mjs +6 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -20,7 +20,7 @@ interface ValidatorTypes {
|
|
|
20
20
|
password: Validator<string, boolean>;
|
|
21
21
|
}
|
|
22
22
|
type ValidatorParams = {
|
|
23
|
-
[K in keyof ValidatorTypes]
|
|
23
|
+
[K in keyof ValidatorTypes]?: ValidatorTypes[K] extends Validator<any, infer U> ? U : never;
|
|
24
24
|
};
|
|
25
25
|
type ValidatorErrorMessage = {
|
|
26
26
|
[K in keyof ValidatorTypes]: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ interface ValidatorTypes {
|
|
|
20
20
|
password: Validator<string, boolean>;
|
|
21
21
|
}
|
|
22
22
|
type ValidatorParams = {
|
|
23
|
-
[K in keyof ValidatorTypes]
|
|
23
|
+
[K in keyof ValidatorTypes]?: ValidatorTypes[K] extends Validator<any, infer U> ? U : never;
|
|
24
24
|
};
|
|
25
25
|
type ValidatorErrorMessage = {
|
|
26
26
|
[K in keyof ValidatorTypes]: string;
|
package/dist/index.js
CHANGED
|
@@ -147,6 +147,11 @@ function useValidation() {
|
|
|
147
147
|
const { lang } = useComponentLanguage();
|
|
148
148
|
const getValidation = (value, isTouched, types, errorMessages) => {
|
|
149
149
|
const items = Object.entries(types), isRequired = items.map(([key]) => key).includes("required");
|
|
150
|
+
if (isRequired && !isTouched)
|
|
151
|
+
return {
|
|
152
|
+
isValid: false,
|
|
153
|
+
validationProps: nxError()
|
|
154
|
+
};
|
|
150
155
|
const validations = items.map(([name, opts]) => {
|
|
151
156
|
const { validate, msg: msg2 } = errors[name];
|
|
152
157
|
return {
|
|
@@ -159,7 +164,7 @@ function useValidation() {
|
|
|
159
164
|
};
|
|
160
165
|
return {
|
|
161
166
|
isValid,
|
|
162
|
-
validationProps:
|
|
167
|
+
validationProps: nxError(!isValid, msg)
|
|
163
168
|
};
|
|
164
169
|
};
|
|
165
170
|
return { getValidation };
|
package/dist/index.mjs
CHANGED
|
@@ -129,6 +129,11 @@ function useValidation() {
|
|
|
129
129
|
const { lang } = useComponentLanguage();
|
|
130
130
|
const getValidation = (value, isTouched, types, errorMessages) => {
|
|
131
131
|
const items = Object.entries(types), isRequired = items.map(([key]) => key).includes("required");
|
|
132
|
+
if (isRequired && !isTouched)
|
|
133
|
+
return {
|
|
134
|
+
isValid: false,
|
|
135
|
+
validationProps: nxError()
|
|
136
|
+
};
|
|
132
137
|
const validations = items.map(([name, opts]) => {
|
|
133
138
|
const { validate, msg: msg2 } = errors[name];
|
|
134
139
|
return {
|
|
@@ -141,7 +146,7 @@ function useValidation() {
|
|
|
141
146
|
};
|
|
142
147
|
return {
|
|
143
148
|
isValid,
|
|
144
|
-
validationProps:
|
|
149
|
+
validationProps: nxError(!isValid, msg)
|
|
145
150
|
};
|
|
146
151
|
};
|
|
147
152
|
return { getValidation };
|