@magmonium/one 0.4.97 → 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.
|
@@ -1844,11 +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 limitMessage = (message, limit, limitName) => `${message}?limit=${limit}${limitName && limitName !== "limit" ? `&${limitName}=${limit}` : ""}`;
|
|
1848
|
-
const
|
|
1849
|
-
const
|
|
1850
|
-
const
|
|
1851
|
-
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()) }));
|
|
1852
1853
|
const manualValidation = (errorMap) => errorMap.forEach(({ error, path }) => validate(path, () => {
|
|
1853
1854
|
const message = error();
|
|
1854
1855
|
return message ? {
|