@juantroconisf/lib 3.1.3 → 3.1.4
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 +1 -0
- package/dist/index.mjs +1 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -55,7 +55,7 @@ type GetValidationResponse = {
|
|
|
55
55
|
isValid: boolean;
|
|
56
56
|
validationProps: NextUIError;
|
|
57
57
|
};
|
|
58
|
-
type GetValidationFunc<V extends unknown> = (value: V, isTouched: boolean, types
|
|
58
|
+
type GetValidationFunc<V extends unknown> = (value: V, isTouched: boolean, types?: ValidatorParams, errorMessages?: ValidatorErrorMessage) => GetValidationResponse;
|
|
59
59
|
interface UseValidationFunc {
|
|
60
60
|
getValidation: GetValidationFunc<unknown>;
|
|
61
61
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -55,7 +55,7 @@ type GetValidationResponse = {
|
|
|
55
55
|
isValid: boolean;
|
|
56
56
|
validationProps: NextUIError;
|
|
57
57
|
};
|
|
58
|
-
type GetValidationFunc<V extends unknown> = (value: V, isTouched: boolean, types
|
|
58
|
+
type GetValidationFunc<V extends unknown> = (value: V, isTouched: boolean, types?: ValidatorParams, errorMessages?: ValidatorErrorMessage) => GetValidationResponse;
|
|
59
59
|
interface UseValidationFunc {
|
|
60
60
|
getValidation: GetValidationFunc<unknown>;
|
|
61
61
|
}
|
package/dist/index.js
CHANGED
|
@@ -153,6 +153,7 @@ function useComponentLanguage() {
|
|
|
153
153
|
function useValidation() {
|
|
154
154
|
const { lang } = useComponentLanguage();
|
|
155
155
|
const getValidation = (value, isTouched, types, errorMessages) => {
|
|
156
|
+
if (!types) return { isValid: true, validationProps: nxError() };
|
|
156
157
|
const items = Object.entries(types), requiredIndex = items.findIndex(([key]) => key === "required"), isRequired = requiredIndex === -1 ? false : items[requiredIndex][1];
|
|
157
158
|
if (value === "" && !isRequired || !isTouched)
|
|
158
159
|
return { isValid: true, validationProps: nxError() };
|
package/dist/index.mjs
CHANGED
|
@@ -134,6 +134,7 @@ function useComponentLanguage() {
|
|
|
134
134
|
function useValidation() {
|
|
135
135
|
const { lang } = useComponentLanguage();
|
|
136
136
|
const getValidation = (value, isTouched, types, errorMessages) => {
|
|
137
|
+
if (!types) return { isValid: true, validationProps: nxError() };
|
|
137
138
|
const items = Object.entries(types), requiredIndex = items.findIndex(([key]) => key === "required"), isRequired = requiredIndex === -1 ? false : items[requiredIndex][1];
|
|
138
139
|
if (value === "" && !isRequired || !isTouched)
|
|
139
140
|
return { isValid: true, validationProps: nxError() };
|