@magmonium/one 0.4.95 → 0.4.97
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/assets/i18n/en.json
CHANGED
|
@@ -524,6 +524,7 @@
|
|
|
524
524
|
"max": "Max",
|
|
525
525
|
"max-drawdown": "Max Drawdown",
|
|
526
526
|
"max-length": "Should contain at most <$len> characters.",
|
|
527
|
+
"max-value": "Should be at most <$limit>.",
|
|
527
528
|
"may": "May",
|
|
528
529
|
"mayotte": "Mayotte",
|
|
529
530
|
"member-since": "Member since",
|
|
@@ -533,6 +534,7 @@
|
|
|
533
534
|
"min": "Min",
|
|
534
535
|
"min-age": "You must be at least <$age> years old.",
|
|
535
536
|
"min-length": "Should contain at least <$len> characters.",
|
|
537
|
+
"min-value": "Should be at least <$limit>.",
|
|
536
538
|
"minute": "minute",
|
|
537
539
|
"minutes": "minutes",
|
|
538
540
|
"miter": "Miter",
|
|
@@ -1843,10 +1843,12 @@ const requiredValidation = (s, paths) => paths.forEach((path) => {
|
|
|
1843
1843
|
} : null;
|
|
1844
1844
|
});
|
|
1845
1845
|
});
|
|
1846
|
-
const
|
|
1847
|
-
const
|
|
1848
|
-
const
|
|
1849
|
-
const
|
|
1846
|
+
const readLimit = (limit) => typeof limit === "function" ? limit() : limit;
|
|
1847
|
+
const limitMessage = (message, limit, limitName) => `${message}?limit=${limit}${limitName && limitName !== "limit" ? `&${limitName}=${limit}` : ""}`;
|
|
1848
|
+
const minLengthValidation = (s, paths, len, message, limitName) => paths.forEach((path) => minLength(s[path], () => readLimit(len), { message: () => message ? limitMessage(message, readLimit(len), limitName) : `min-length?len=${readLimit(len)}` }));
|
|
1849
|
+
const maxLengthValidation = (s, paths, len, message, limitName) => paths.forEach((path) => maxLength(s[path], () => readLimit(len), { message: () => message ? limitMessage(message, readLimit(len), limitName) : `max-length?len=${readLimit(len)}` }));
|
|
1850
|
+
const minValidation = (s, paths, limit, message = "min-value", limitName) => paths.forEach((path) => min(s[path], () => readLimit(limit), { message: () => limitMessage(message, readLimit(limit), limitName) }));
|
|
1851
|
+
const maxValidation = (s, paths, limit, message = "max-value", limitName) => paths.forEach((path) => max(s[path], () => readLimit(limit), { message: () => limitMessage(message, readLimit(limit), limitName) }));
|
|
1850
1852
|
const manualValidation = (errorMap) => errorMap.forEach(({ error, path }) => validate(path, () => {
|
|
1851
1853
|
const message = error();
|
|
1852
1854
|
return message ? {
|
|
@@ -1854,18 +1856,20 @@ const manualValidation = (errorMap) => errorMap.forEach(({ error, path }) => val
|
|
|
1854
1856
|
message
|
|
1855
1857
|
} : null;
|
|
1856
1858
|
}));
|
|
1857
|
-
const minAgeValidation = (schemaPath, minAge, dateFormat = "YYYY-MM-DD") => validate(schemaPath, (ctx) => {
|
|
1859
|
+
const minAgeValidation = (schemaPath, minAge, dateFormat = "YYYY-MM-DD", message, limitName) => validate(schemaPath, (ctx) => {
|
|
1858
1860
|
const value = ctx.value();
|
|
1859
1861
|
if (!value) return null;
|
|
1862
|
+
const limit = readLimit(minAge);
|
|
1863
|
+
if (limit === void 0) return null;
|
|
1860
1864
|
const birthDate = parseDate(value, dateFormat);
|
|
1861
1865
|
if (!birthDate) return null;
|
|
1862
1866
|
const today = /* @__PURE__ */ new Date();
|
|
1863
1867
|
const age = today.getFullYear() - birthDate.getFullYear();
|
|
1864
1868
|
const monthDiff = today.getMonth() - birthDate.getMonth();
|
|
1865
1869
|
const dayDiff = today.getDate() - birthDate.getDate();
|
|
1866
|
-
return (monthDiff < 0 || monthDiff === 0 && dayDiff < 0 ? age - 1 : age) <
|
|
1870
|
+
return (monthDiff < 0 || monthDiff === 0 && dayDiff < 0 ? age - 1 : age) < limit ? {
|
|
1867
1871
|
kind: "minAge",
|
|
1868
|
-
message: `min-age?age=${
|
|
1872
|
+
message: message ? limitMessage(message, limit, limitName) : `min-age?age=${limit}`
|
|
1869
1873
|
} : null;
|
|
1870
1874
|
});
|
|
1871
1875
|
const matchFieldValidation = (schemaPath, matchSchemaPath, fieldLabel) => validate(schemaPath, (ctx) => {
|