@yomologic/react-ui 0.6.3 → 0.6.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 +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +12 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -25,13 +25,16 @@ var EMAIL_REGEX, URL_REGEX, PHONE_REGEX, isValidEmail, isValidUrl, DATE_REGEX, i
|
|
|
25
25
|
var init_validation = __esm({
|
|
26
26
|
"src/constants/validation.ts"() {
|
|
27
27
|
"use strict";
|
|
28
|
-
EMAIL_REGEX = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](
|
|
28
|
+
EMAIL_REGEX = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z]{2,}$/;
|
|
29
29
|
URL_REGEX = /^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$/;
|
|
30
30
|
PHONE_REGEX = /^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$/;
|
|
31
31
|
isValidEmail = (email) => {
|
|
32
32
|
return EMAIL_REGEX.test(email);
|
|
33
33
|
};
|
|
34
34
|
isValidUrl = (url) => {
|
|
35
|
+
if (/^(javascript|data|vbscript|file|about):/i.test(url)) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
35
38
|
return URL_REGEX.test(url);
|
|
36
39
|
};
|
|
37
40
|
DATE_REGEX = /^(0[1-9]|1[0-2])\/(0[1-9]|[12][0-9]|3[01])\/\d{4}$/;
|
|
@@ -909,6 +912,9 @@ function useFormField2(options) {
|
|
|
909
912
|
return errorMessages?.email || "Please enter a valid email address";
|
|
910
913
|
}
|
|
911
914
|
if (type === "url") {
|
|
915
|
+
if (/^(javascript|data|vbscript|file|about):/i.test(value)) {
|
|
916
|
+
return errorMessages?.url || "Invalid URL protocol";
|
|
917
|
+
}
|
|
912
918
|
try {
|
|
913
919
|
new URL(value);
|
|
914
920
|
} catch {
|
|
@@ -966,6 +972,11 @@ function useFormField2(options) {
|
|
|
966
972
|
return errorMessages?.email || "Please enter a valid email address";
|
|
967
973
|
}
|
|
968
974
|
if (type === "url") {
|
|
975
|
+
if (/^(javascript|data|vbscript|file|about):/i.test(
|
|
976
|
+
value
|
|
977
|
+
)) {
|
|
978
|
+
return errorMessages?.url || "Invalid URL protocol";
|
|
979
|
+
}
|
|
969
980
|
try {
|
|
970
981
|
new URL(value);
|
|
971
982
|
} catch {
|