foxit-component 1.0.3-alpha.5 → 1.0.3-alpha.8
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/es/Form/FormProvider.js +28 -4
- package/package.json +1 -1
package/es/Form/FormProvider.js
CHANGED
|
@@ -69,13 +69,36 @@ var FormProvider = function (_a, ref) {
|
|
|
69
69
|
if (rule.type === 'email' && value && !/\S+@\S+\.\S+/.test(value)) {
|
|
70
70
|
return { type: 'error', message: rule.message || 'The input is not valid E-mail' };
|
|
71
71
|
}
|
|
72
|
-
if (rule.type === 'number'
|
|
73
|
-
|
|
72
|
+
if (rule.type === 'number') {
|
|
73
|
+
if (value && isNaN(Number(value))) {
|
|
74
|
+
return { type: 'error', message: rule.message || 'The input is not a number' };
|
|
75
|
+
}
|
|
76
|
+
if (rule.min !== undefined && value && Number(value) < rule.min) {
|
|
77
|
+
return { type: 'error', message: rule.message || "The input is less than ".concat(rule.min) };
|
|
78
|
+
}
|
|
79
|
+
if (rule.max !== undefined && value && Number(value) > rule.max) {
|
|
80
|
+
return { type: 'error', message: rule.message || "The input is more than ".concat(rule.max) };
|
|
81
|
+
}
|
|
74
82
|
}
|
|
75
|
-
if (rule.type === 'string'
|
|
76
|
-
|
|
83
|
+
if (rule.type === 'string') {
|
|
84
|
+
if (value && typeof value !== 'string') {
|
|
85
|
+
return { type: 'error', message: rule.message || 'The input is not a string' };
|
|
86
|
+
}
|
|
87
|
+
if (rule.min !== undefined && value && value.length < rule.min) {
|
|
88
|
+
return {
|
|
89
|
+
type: 'error',
|
|
90
|
+
message: rule.message || "The input is less than ".concat(rule.min, " characters")
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
if (rule.max !== undefined && value && value.length > rule.max) {
|
|
94
|
+
return {
|
|
95
|
+
type: 'error',
|
|
96
|
+
message: rule.message || "The input is more than ".concat(rule.max, " characters")
|
|
97
|
+
};
|
|
98
|
+
}
|
|
77
99
|
}
|
|
78
100
|
if (rule.min !== undefined &&
|
|
101
|
+
rule.type === undefined &&
|
|
79
102
|
typeof value === 'string' &&
|
|
80
103
|
new Blob([value]).size < rule.min) {
|
|
81
104
|
return {
|
|
@@ -84,6 +107,7 @@ var FormProvider = function (_a, ref) {
|
|
|
84
107
|
};
|
|
85
108
|
}
|
|
86
109
|
if (rule.max !== undefined &&
|
|
110
|
+
rule.type === undefined &&
|
|
87
111
|
typeof value === 'string' &&
|
|
88
112
|
new Blob([value]).size > rule.max) {
|
|
89
113
|
return {
|