@magmonium/one 0.4.96 → 0.4.98
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,12 @@ 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, value) => `${message}?limit=${limit}${value == null ? "" : `&value=${value}`}${limitName && limitName !== "limit" ? `&${limitName}=${limit}` : ""}`;
|
|
1848
|
+
const lengthOf = (value) => typeof value === "string" || Array.isArray(value) ? value.length : null;
|
|
1849
|
+
const minLengthValidation = (s, paths, len, message, limitName) => paths.forEach((path) => minLength(s[path], () => readLimit(len), { message: (ctx) => message ? limitMessage(message, readLimit(len), limitName, lengthOf(ctx.value())) : `min-length?len=${readLimit(len)}` }));
|
|
1850
|
+
const maxLengthValidation = (s, paths, len, message, limitName) => paths.forEach((path) => maxLength(s[path], () => readLimit(len), { message: (ctx) => message ? limitMessage(message, readLimit(len), limitName, lengthOf(ctx.value())) : `max-length?len=${readLimit(len)}` }));
|
|
1851
|
+
const minValidation = (s, paths, limit, message = "min-value", limitName) => paths.forEach((path) => min(s[path], () => readLimit(limit), { message: (ctx) => limitMessage(message, readLimit(limit), limitName, ctx.value()) }));
|
|
1852
|
+
const maxValidation = (s, paths, limit, message = "max-value", limitName) => paths.forEach((path) => max(s[path], () => readLimit(limit), { message: (ctx) => limitMessage(message, readLimit(limit), limitName, ctx.value()) }));
|
|
1851
1853
|
const manualValidation = (errorMap) => errorMap.forEach(({ error, path }) => validate(path, () => {
|
|
1852
1854
|
const message = error();
|
|
1853
1855
|
return message ? {
|
|
@@ -1855,7 +1857,7 @@ const manualValidation = (errorMap) => errorMap.forEach(({ error, path }) => val
|
|
|
1855
1857
|
message
|
|
1856
1858
|
} : null;
|
|
1857
1859
|
}));
|
|
1858
|
-
const minAgeValidation = (schemaPath, minAge, dateFormat = "YYYY-MM-DD") => validate(schemaPath, (ctx) => {
|
|
1860
|
+
const minAgeValidation = (schemaPath, minAge, dateFormat = "YYYY-MM-DD", message, limitName) => validate(schemaPath, (ctx) => {
|
|
1859
1861
|
const value = ctx.value();
|
|
1860
1862
|
if (!value) return null;
|
|
1861
1863
|
const limit = readLimit(minAge);
|
|
@@ -1868,7 +1870,7 @@ const minAgeValidation = (schemaPath, minAge, dateFormat = "YYYY-MM-DD") => vali
|
|
|
1868
1870
|
const dayDiff = today.getDate() - birthDate.getDate();
|
|
1869
1871
|
return (monthDiff < 0 || monthDiff === 0 && dayDiff < 0 ? age - 1 : age) < limit ? {
|
|
1870
1872
|
kind: "minAge",
|
|
1871
|
-
message: `min-age?age=${limit}`
|
|
1873
|
+
message: message ? limitMessage(message, limit, limitName) : `min-age?age=${limit}`
|
|
1872
1874
|
} : null;
|
|
1873
1875
|
});
|
|
1874
1876
|
const matchFieldValidation = (schemaPath, matchSchemaPath, fieldLabel) => validate(schemaPath, (ctx) => {
|