@magmonium/one 0.4.96 → 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",
|
|
@@ -1844,10 +1844,11 @@ const requiredValidation = (s, paths) => paths.forEach((path) => {
|
|
|
1844
1844
|
});
|
|
1845
1845
|
});
|
|
1846
1846
|
const readLimit = (limit) => typeof limit === "function" ? limit() : limit;
|
|
1847
|
-
const
|
|
1848
|
-
const
|
|
1849
|
-
const
|
|
1850
|
-
const
|
|
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) }));
|
|
1851
1852
|
const manualValidation = (errorMap) => errorMap.forEach(({ error, path }) => validate(path, () => {
|
|
1852
1853
|
const message = error();
|
|
1853
1854
|
return message ? {
|
|
@@ -1855,7 +1856,7 @@ const manualValidation = (errorMap) => errorMap.forEach(({ error, path }) => val
|
|
|
1855
1856
|
message
|
|
1856
1857
|
} : null;
|
|
1857
1858
|
}));
|
|
1858
|
-
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) => {
|
|
1859
1860
|
const value = ctx.value();
|
|
1860
1861
|
if (!value) return null;
|
|
1861
1862
|
const limit = readLimit(minAge);
|
|
@@ -1868,7 +1869,7 @@ const minAgeValidation = (schemaPath, minAge, dateFormat = "YYYY-MM-DD") => vali
|
|
|
1868
1869
|
const dayDiff = today.getDate() - birthDate.getDate();
|
|
1869
1870
|
return (monthDiff < 0 || monthDiff === 0 && dayDiff < 0 ? age - 1 : age) < limit ? {
|
|
1870
1871
|
kind: "minAge",
|
|
1871
|
-
message: `min-age?age=${limit}`
|
|
1872
|
+
message: message ? limitMessage(message, limit, limitName) : `min-age?age=${limit}`
|
|
1872
1873
|
} : null;
|
|
1873
1874
|
});
|
|
1874
1875
|
const matchFieldValidation = (schemaPath, matchSchemaPath, fieldLabel) => validate(schemaPath, (ctx) => {
|